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? Link to comment https://forums.phpfreaks.com/topic/287280-syntax-error/ Share on other sites More sharing options...
mac_gyver Posted March 26, 2014 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 Link to comment https://forums.phpfreaks.com/topic/287280-syntax-error/#findComment-1473913 Share on other sites More sharing options...
adamjones Posted March 26, 2014 Author Share Posted March 26, 2014 Thank you :-D Link to comment https://forums.phpfreaks.com/topic/287280-syntax-error/#findComment-1473915 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.