Styles2304 Posted August 20, 2007 Share Posted August 20, 2007 Ok, in the link to the page in question, it passes the variable saying letter=C. Then, at the top of the page in question it does: $letter = $_GET['letter']; $letter = $letter . "%"; Which, when echoed, spits out C%. Now, when I set up my query, I do this: $query = "SELECT * FROM Directory ORDER BY LastName WHERE LastName LIKE '" . $letter . "'"; Which results in: 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 'WHERE LastName LIKE 'C%'' at line 1 Does anyone see the mistake I'm making? the names of the variables are all correct. Quote Link to comment https://forums.phpfreaks.com/topic/65767-solved-not-quite-sure-how-to-go-about-this-ends-in-syntax-error/ Share on other sites More sharing options...
The Little Guy Posted August 20, 2007 Share Posted August 20, 2007 $query = "SELECT * FROM Directory WHERE LastName LIKE '$letter' ORDER BY LastName"; Quote Link to comment https://forums.phpfreaks.com/topic/65767-solved-not-quite-sure-how-to-go-about-this-ends-in-syntax-error/#findComment-328549 Share on other sites More sharing options...
Styles2304 Posted August 20, 2007 Author Share Posted August 20, 2007 :: slap forehead :: Thanks Quote Link to comment https://forums.phpfreaks.com/topic/65767-solved-not-quite-sure-how-to-go-about-this-ends-in-syntax-error/#findComment-328552 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.