0

Hey all

What is with this query

$query = mysql_query("UPDATE `namitposts` SET `title` = '$topic' , `date` = '$date' ', `postee` = '$postee', `post` = '$post_text' , `ip` = '$ip' WHERE `id` = '$del'") . mysql_error();

Its not passing the variables am getting this error message


Notice: Query error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'postee--', `post` = 'post
--asdfsafasf' , `ip` = '83.70.242 SQL: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'postee--', `post` = 'post
--asdfsafasf' , `ip` = '83.70.242 in /home/namit/public_html/admin/index.php on line 162

3
Contributors
2
Replies
7
Views
11 Years
Discussion Span
Last Post by Ooble
0

$query = mysql_query("UPDATE `namitposts` SET `title` = '$topic' , `date` = '$date' ', `postee` = '$postee', `post` = '$post_text' , `ip` = '$ip' WHERE `id` = '$del'") . mysql_error();

Needs to be:
$query = mysql_query("UPDATE namitposts SET title = '" . $topic . "', date = '" . $date . "', postee........

0

No... the code is fine... double quotes in PHP tell it to parse the string for variable names and replace as necessary.

Why are you concatenating the mysql_query return value with the mysql_error return value?

Try this:

$sql = "UPDATE `namitposts` SET `title` = '$topic' , `date` = '$date' ', `postee` = '$postee', `post` = '$post_text' , `ip` = '$ip' WHERE `id` = '$del'";
if ($query = mysql_query($sql))
{
    // do stuff
}
else
{
    echo '<pre>' . $sql . "\n" . mysql_error() . '</pre>';
}

If it fails, scan the SQL for any errors.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.