mishasoni Posted October 15, 2008 Share Posted October 15, 2008 PHP newbie here. I am getting a SQL syntax error on the following code: $query_rsParticipants = "SELECT * FROM Contacts WHERE ContactType = 'Scientist' AND ContactID_pk <> 0 ORDER BY NameLast ASC"; The exact error message is: "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 'ORDER BY NameLast ASC LIMIT 0, 30' at line 1" For the life of me I can't figure out what is wrong as it was working previously. Any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/128583-sql-syntax-error/ Share on other sites More sharing options...
kenrbnsn Posted October 15, 2008 Share Posted October 15, 2008 The "not equal" operator is "!=", not "<>". Ken Quote Link to comment https://forums.phpfreaks.com/topic/128583-sql-syntax-error/#findComment-666377 Share on other sites More sharing options...
revraz Posted October 15, 2008 Share Posted October 15, 2008 And that looks like the wrong line, I dont see a LIMIT 0, 30 on that query. Quote Link to comment https://forums.phpfreaks.com/topic/128583-sql-syntax-error/#findComment-666379 Share on other sites More sharing options...
mishasoni Posted October 15, 2008 Author Share Posted October 15, 2008 Changing the operator didn't work. Now the error just 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 'ORDER BY NameLast ASC' at line 1". The only line of code containing this text on the page is the one I previously provided. Quote Link to comment https://forums.phpfreaks.com/topic/128583-sql-syntax-error/#findComment-666392 Share on other sites More sharing options...
revraz Posted October 15, 2008 Share Posted October 15, 2008 Put single quotes around the 0 AND ContactID_pk <> '0' And there had to be another line, unless you removed the LIMIT. Quote Link to comment https://forums.phpfreaks.com/topic/128583-sql-syntax-error/#findComment-666394 Share on other sites More sharing options...
mishasoni Posted October 15, 2008 Author Share Posted October 15, 2008 Also, running a recordset test in Dreamweaver works fine with no errors. Quote Link to comment https://forums.phpfreaks.com/topic/128583-sql-syntax-error/#findComment-666449 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.