etsted Posted May 12, 2014 Share Posted May 12, 2014 Can someone tell me whats wrong with this code? I just cant see it $sql = "SELECT * FROM conversation WHERE from='$log_username' AND deleted='0' "; error caused: 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 'from='jacop' AND deleted='0' '' at line 1 Link to comment Share on other sites More sharing options...
Ingolme Posted May 12, 2014 Share Posted May 12, 2014 FROM is an SQL keyword, so you'll have to wrap it in backticks: `from`='$log_username' Link to comment Share on other sites More sharing options...
etsted Posted May 12, 2014 Author Share Posted May 12, 2014 got 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 'to, from, date_sent, message, subject FROM conversation WHERE `from`='jacop' AND' at line 1 while trying this: $sql = "SELECT id, to, from, date_sent, message, subject FROM conversation WHERE `from`='$log_username' AND deleted='0' "; Link to comment Share on other sites More sharing options...
Ingolme Posted May 12, 2014 Share Posted May 12, 2014 Actually, the same problem is occurring because you have another "from" in the query. SELECT id, to, from, Link to comment Share on other sites More sharing options...
justsomeguy Posted May 12, 2014 Share Posted May 12, 2014 "To" is also a reserved word.http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now