adamjones Posted March 26, 2014 Share Posted March 26, 2014 Hi, I'm getting 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 'read='0'' at line 1 With this code; $msg = mysql_query("SELECT * FROM `messages` WHERE toid='$id' AND read='0'") or die(mysql_error()); $messages = mysql_num_rows($msg); It works fine if I remove "read='0'"... :-( Any ideas? Quote Link to comment Share on other sites More sharing options...
Solution mac_gyver Posted March 26, 2014 Solution Share Posted March 26, 2014 read is a reserved keyword. either rename the column to something else or put back-ticks `read` around the column name every time you use it in a query. ref: http://dev.mysql.com/doc/refman/5.6/en/reserved-words.html Quote Link to comment Share on other sites More sharing options...
adamjones Posted March 26, 2014 Author Share Posted March 26, 2014 Thank you :-D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.