SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Kentucky, USA
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is there something im missing in this query?

    PHP Code:
    $query "SELECT id, date, story, ext_date, source, location, status_col, reference, locext, colf FROM fl_waterufo
       WHERE location LIKE '%
    $_POST['search']%' OR reference LIKE '%$_POST['search']%' OR story LIKE '%$_POST['search']%'"
    It shows EVERYTHING in the database. Nothing even relates to the word i use in the search. Its been a while since iv done php, so im lil rusty. Help me out please.

  2. #2
    SitePoint Zealot Selatos's Avatar
    Join Date
    Aug 2002
    Location
    USA
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by killer2239
    PHP Code:
    $query "SELECT id, date, story, ext_date, source, location, status_col, reference, locext, colf FROM fl_waterufo
    WHERE location LIKE '%
    $_POST['search']%' OR reference LIKE '%$_POST['search']%' OR story LIKE '%$_POST['search']%'"
    It shows EVERYTHING in the database. Nothing even relates to the word i use in the search. Its been a while since iv done php, so im lil rusty. Help me out please.
    The quotes look a little bit weird to me. I would try redoing it using single-quotes because it is
    a) faster and more efficient when it comes to processing
    b) no pesky quote escaping
    c) easy to detect mistakes(if you have an editor which text highlights)
    ]
    PHP Code:
    $query 'SELECT id, date, story, ext_date, source, location, status_col, reference, locext, colf FROM fl_waterufo
    WHERE location LIKE "%'
    .$_POST['search'].'%" OR reference LIKE "%'.$_POST['search'].'%" OR story LIKE "%'.$_POST['search'].'%"'


Bookmarks

Posting Permissions

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