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. 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"; 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 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
Archived
This topic is now archived and is closed to further replies.