954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

passing variables threw query

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

namit
Light Poster
44 posts since Jun 2005
Reputation Points: 10
Solved Threads: 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........

madmital
Junior Poster
120 posts since Jun 2005
Reputation Points: 10
Solved Threads: 5
 

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:
[php]$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 '' . $sql . "\n" . mysql_error() . '';
}[/php]
If it fails, scan the SQL for any errors.

Ooble
Light Poster
44 posts since Oct 2005
Reputation Points: 12
Solved Threads: 6
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You