Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Query using letter not working ??

    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

    PHP Code:
    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 ??


  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    select * from azidx where azid = '$_GET[idx]'
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh sugggarrrrr

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



    Thanks spooks


  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •