Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Location
    UK
    Posts
    709

    whats going on?!

    Hi all,

    Today i deleted a feature from my site which i then wanted to keep... not having backups i had to remake it...

    I'm having trouble with this simple query, using the LIKE statement.

    here's what i got

    $query = 'SELECT * FROM items WHERE item_name LIKE "'.$displayby.'%"';

    it should display all items on the site beginning with the appropriate letter, depending what they clicked on.

    It doesnt! It displays no results as though there are no items, but if i were to change the query and remove the variable, and put a letter in its place, it DOES display all the items. Ive torn my hair out for the last 40 minutes trying to get it working...

    please please please help!

    Thanks

    Mat...

  2. #2
    Join Date
    Mar 2002
    Location
    Denmark
    Posts
    684
    do you get an SQL error or do you just not get any results shown?

    as it seems to be fine, what you could do is print out the query to make sure that you get the SQL query you want...
    ~Chris

  3. #3
    Join Date
    May 2004
    Location
    UK
    Posts
    709
    hey, i was just getting no results at all, but i did get an sql error when i tried working on other ways around it.

    I worked it out in the end. Basically, the links i was using to pass the $displayby variable, had single quotes around them, so the final query was looking for items begiinning with 'e' which of course doesnt exist, so a quick string replace sorted that out to get rid of the ' 's so now its working fine.

    Thanks for the feedback though

    Mat.

Posting Permissions

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