Jump to content

[SOLVED] Not quite sure how to go about this . . . ends in syntax error


Styles2304

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.