dean7 Posted November 19, 2010 Share Posted November 19, 2010 Hi, i'm currently coding a new inbox for my website, but ive got an error which says: 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 'to='NoName' ORDER BY id DESC' at line 1 Im not sure why ive got that as everything seems to be fine :S My Code: $user=$_SESSION['username']; $get_messages = mysql_query("SELECT `id` FROM `inbox` WHERE to='$user' ORDER BY `id` DESC") or die("Error on line 9 - " . mysql_error()); Thanks for any help/advise given. Link to comment https://forums.phpfreaks.com/topic/219209-error-in-query/ Share on other sites More sharing options...
jdavidbakr Posted November 19, 2010 Share Posted November 19, 2010 is 'to' the name of your column? It's a reserved word, so you need to enclose it in back-ticks. $user=$_SESSION['username']; $get_messages = mysql_query("SELECT `id` FROM `inbox` WHERE `to`='$user' ORDER BY `id` DESC") or die("Error on line 9 - " . mysql_error()); Link to comment https://forums.phpfreaks.com/topic/219209-error-in-query/#findComment-1136731 Share on other sites More sharing options...
dean7 Posted November 19, 2010 Author Share Posted November 19, 2010 is 'to' the name of your column? It's a reserved word, so you need to enclose it in back-ticks. $user=$_SESSION['username']; $get_messages = mysql_query("SELECT `id` FROM `inbox` WHERE `to`='$user' ORDER BY `id` DESC") or die("Error on line 9 - " . mysql_error()); Yeah thanks, that made it work Link to comment https://forums.phpfreaks.com/topic/219209-error-in-query/#findComment-1136734 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.