Pi_Mastuh Posted January 24, 2011 Share Posted January 24, 2011 I am trying to run a select query, and am not sure why I'm getting a syntax error. $SQL2 = "SELECT * FROM messages WHERE to='$username' OR (to='ALL' AND busID='$busID')"; $result = mysql_query($SQL2,$connection) or die(mysql_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 'to='lynsey93' OR (to='ALL' AND busID='1')' at line 1" Could anybody shed some light on the situation? Quote Link to comment Share on other sites More sharing options...
Maq Posted January 24, 2011 Share Posted January 24, 2011 'To' is a reserved MySQL word. You either have to use backticks `to` around it every time you use it, or rename that column. Quote Link to comment Share on other sites More sharing options...
Pi_Mastuh Posted January 25, 2011 Author Share Posted January 25, 2011 Makes sense, thanks! Quote Link to comment Share on other sites More sharing options...
Maq Posted January 25, 2011 Share Posted January 25, 2011 Makes sense, thanks! If this issue has been resolved please mark as so. 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.