#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    I've created my first search form and it seems everything is working pretty well. However, since I am very novice in scripting in general, I'm having one problem that I can't seem to unearth an answer to. Perhaps someone could easily offer the answer:

    my query asks to select a 2 char state code or a 5 digit zip code in order to obtain results desired. In testing, if I enter a state code, it brings up only the state requested. However, when I enter a zipcode, I get the wrong results. I'm sure its the "LIKE" that is throwing this off. Here is the query portion of the script:

    $result = mysql_query ("SELECT * FROM fish_dealers
    WHERE Zip = $Zip%

    OR State LIKE $State%
    ");


    Can anyone give me a clue?

    Thanks,

    mary
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    4
    Rep Power
    0
    The wildcards '%' and '_' will only match when used with a 'LIKE'. If you are using '=' then it will treat them as an ordinary '%' and '_'.

Similar Threads

  1. Check MySQL Version thru PHP
    By wolftrap1 in forum PHP Development
    Replies: 2
    Last Post: February 11th, 2004, 09:51 PM
  2. Replies: 0
    Last Post: January 30th, 2004, 02:22 PM
  3. MySQL Select query
    By MrTee1 in forum MySQL Help
    Replies: 0
    Last Post: January 30th, 2004, 12:16 PM
  4. PHP to import csf into mysql
    By benjimcc in forum PHP Development
    Replies: 1
    Last Post: January 28th, 2004, 01:26 PM
  5. PHP 5 (MYSQL vs. SQLite)
    By ignition in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 01:13 PM

IMN logo majestic logo threadwatch logo seochat tools logo