doforumda Posted June 28, 2010 Share Posted June 28, 2010 hi i am using an update query but it is not working. it gives 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='read' WHERE mid='2'' at line 1 here is my query $mid = $_GET['mid']; $msg = mysql_query("SELECT * FROM messages WHERE mid='$mid'") or die(mysql_error()); if(mysql_num_rows($msg) > 0) { $row_read = mysql_fetch_assoc($msg); $read_db = $row_read['read']; if($read_db == 'unread') { //echo "unread"; $read = mysql_query("UPDATE messages SET read='read' WHERE mid='$mid'") or die(mysql_error()); } } Link to comment https://forums.phpfreaks.com/topic/206047-need-help-in-update-query/ Share on other sites More sharing options...
trq Posted June 28, 2010 Share Posted June 28, 2010 Store your query within a variable and then echo it, its the easiest way to debug these issues. Link to comment https://forums.phpfreaks.com/topic/206047-need-help-in-update-query/#findComment-1078167 Share on other sites More sharing options...
PFMaBiSmAd Posted June 28, 2010 Share Posted June 28, 2010 http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html Link to comment https://forums.phpfreaks.com/topic/206047-need-help-in-update-query/#findComment-1078312 Share on other sites More sharing options...
doforumda Posted June 28, 2010 Author Share Posted June 28, 2010 when i echo this query it displays this UPDATE messages SET read='read' WHERE mid='2' which is correct i guess Link to comment https://forums.phpfreaks.com/topic/206047-need-help-in-update-query/#findComment-1078357 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.