SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    multiple search problem

    Hi guys

    Trying to make a multiple search

    // Build SQL Query
    $query = "select * from jobs where catergory,location,salary,jobstatus like \"%$trimmed%\"
    order by catergory"; // EDIT HERE and specify your table and field names for the SQL query

    I am getting this error

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/notexper/public_html/getsearch.php on line 102

    Thanks in advance for your help

  2. #2
    Chessplayer kleineme's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you want to match every column against \"%$trimmed%\" ? Then you have to say so explicitly:

    PHP Code:
    $query 
    "select * from jobs
    where catergory like \"%
    $trimmed%\" 
    OR location like \"%
    $trimmed%\"
    OR salary like \"%
    $trimmed%\"
    OR jobstatus like \"%
    $trimmed%\"
    order by catergory"

    And is it really "catergory"?
    Never ascribe to malice,
    that which can be explained by incompetence.
    Your code should not look unmaintainable, just be that way.

  3. #3
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    // Build SQL Query
    $query mysql_query("SELECT * FROM jobs WHERE catergory,location,salary,jobstatus LIKE \"%$trimmed%\"
    ORDER BY catergory"
    ) or die(mysql_error()); 
    Your query is failing, probably for the typo as specified above. capitilisation as shown makes it easier to read. Run this and see what the mysql error is.
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development


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
  •