I have been struggling with this problem for days. I have done everything in my power to find the answer but can't seem to figure it out. I want to parse the information from a form into my database, but I keep getting errors. The error apparently is on line 27 in this php parse code.

<?php
/* Created by Adam Khoury @ [url]www.developphp.com[/url] */

// You may want to obtain refering site name that this post came from for security purposes here
// exit the script if it is not from your site and script
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$pid = $_POST['id'];
$pagetitle = $_POST['pagetitle'];
$author = $_POST["author_id"];
$keywords = $_POST["keywords"];
$description = $_POST["description"];
$pagebody = $_POST['pagebody'];
// Filter Function -------------------------------------------------------------------
function filterFunction ($var) { 
    $var = nl2br(htmlspecialchars($var));
    $var = eregi_replace("'", "'", $var);
    $var = eregi_replace("`", "'", $var);		
    return $var; 
} 
$pagetitle = filterFunction($pagetitle);
$author = filterFunction($author);
$keywords = filterFunction($keywords);
$description = filterFunction($description);
// End Filter Function --------------------------------------------------------------
include_once "scripts/connect_to_mysql.php";
// Add the updated info into the database table
$query = mysqli_query($myConnection, "UPDATE pages SET pagetitle='$pagetitle', author_id='$author', keywords='$keywords', description='$description', pagebody='$pagebody', lastmodified='now()' WHERE id='$pid'") or die (mysqli_error($myConnection)); // <--- line 27 here

echo 'Operation Completed Successfully! <br /><br /><a href="my_articles.php">Click Here</a>';
exit();
?>

I place the code in question in bold letters. Please help. This is getting frustrating.

    Welcome to PHPBuilder! When posting PHP code, please use the board's [noparse]

    ..

    [/noparse] bbcode tags as they make your code much easier to read and analyze. (I replaced your use of bold text with a code comment indicating which line you're referencing.)

    As for your issue... where is $myConnection defined?

      That helped. I fixed the problem.

      Now I have a different one.

      How to I properly apply this variable within this string?

      $check_pic = "videoThumbs/$vid.jpg";

      I can't seem to get the $vid variable to render properly.

        I should have clarified that the variable is already defined. All I would like to know is how to properly write the code. For some reason if I write the variable this way:

        $check_pic = "videoThumbs/$vid/image01.jpg";

        my image renders just fine, but I don't want to create tons of directories just to display images where I want them. I just want to change the image01 to a $vid variable to sync the image with the information in my database. If I can get this one line of code to work, everything will render exactly the way I want it to.

          Fixed it already. I didn't have the image file in the right place lol. 🙂

          Thanks anyway.

            Write a Reply...