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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.