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. Quote Link to comment 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()); Quote Link to comment 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 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.