View Full Version : Query using letter not working ??

11-25-2002, 04:33 PM
Hello everyone

I am currently setting up an az-index page which will pull results from my database based on the letter which is passed in the link e.g az_index.php?idx=a, will pull all the items with 'a'

I have a table called azidx with three fields name (azid, name, sub_id). I have a query which says

select * from azidx where azid = $_GET[idx]

this does not seem to work for some reason. If I replace all the instances of the letter 'a', with for example 0. Then call it again using az_index.php?idx=0 it will work.

Any ideas on why it won't work using letter the first way. Do I need to use a certain field type ??
I tried several but no luck. Its not set as a primary key because I have lots of instances of a and b etc but that shouldn't matter.

Any ideas ?? im abit confused ??


11-25-2002, 04:38 PM
select * from azidx where azid = '$_GET[idx]'

11-25-2002, 04:48 PM
oh sugggarrrrr

how stupid am I. I was looking at that for ages and couldn't understand why.


Thanks spooks


11-25-2002, 05:27 PM
That's a common mistake. :) If you want it to be treated as a string/character then it must be enclosed in quotes. Your letters were probably being interpreted as ascii equivalents so the query would have produced nothing.