Jump to content

Little Problem! Mysql and PHP Problem! Please Help


paulman888888

Recommended Posts

Simple Question; What have i done wrong again?

Its my little search engine page. Have more than one table the user can search. I have limited the tables the user can see so theres no sercurity problem.

 

Heres the code

// Build SQL Query  
$query = "SELECT * FROM `$search_where` WHERE '$search_name' LIKE \"%$trimmed%\"  ORDER BY id"; // EDIT HERE and specify your table and field names for the SQL query

$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);//this is line 62

Heres the error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/paul/public_html/page/search.php on line 62

EDIT: I have just done another try and i got no errors but i also got no search results. I no theres is some but why am i not getting any?

 

Thankyou all in advance

Paul

Link to comment
Share on other sites

It meas that line 61 ($numresults=mysql_query($query);) is does not contain a valid query.  Did you connect to the DB server and select a BD

 

Side Note: There is still a potentail security problem there.

change  LIKE \"%$trimmed%\"  ORD

to

LIKE \"%" . mysql_real_escape_string($trimmed) . "%\"  ORD

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.