Page 1 of 1

MySql error

Posted: Wed Aug 26, 2009 8:37 pm
by crazymao
i get this 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 'WHERE id=' at line 1

this is my code:
mysql_query("SELECT id,message FROM $subject WHERE id=$id") or die ('Error: '.mysql_error ());

im confused because i (think) that the problem is with the $subject because when i replace it it works (more or less) and i use it (with the $subject) in another script which works. i assign the $subject earlier in the script so what the ....

Re: MySql error

Posted: Wed Aug 26, 2009 9:44 pm
by requinix
Print the query before you run it - $subject is probably empty.

Re: MySql error

Posted: Thu Aug 27, 2009 2:55 am
by klevis miho
You should make it like that:

mysql_query("SELECT id,message FROM '$subject' WHERE id='$id'") or die ('Error: '.mysql_error ());