By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,092 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,092 IT Pros & Developers. It's quick & easy.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

P: 1
I am getting the following error messages in my search:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 113

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 127

My code is below. Any help would be much appreciated.

************************************************** ***************************************
Expand|Select|Wrap|Line Numbers
  1. <?
  2. //This is only displayed if they have submitted the form
  3. if ($searching =="yes")
  4. {
  5. echo "<h2>Results</h2><p>";
  6.  
  7. //If they did not enter a search term we give them an error
  8. if ($find == "")
  9. {
  10. echo "<p>You forgot to enter a search term";
  11. exit;
  12. }
  13.  
  14. // Otherwise we connect to our Database
  15. mysql_connect("host", "*****", "*****") or die(mysql_error());
  16. mysql_select_db("DBname") or die(mysql_error());
  17.  
  18. // We preform a bit of filtering
  19. $find = strtoupper($find);
  20. $find = strip_tags($find);
  21. $find = trim ($find);
  22.  
  23. //Now we search for our search term, in the field the user specified
  24. $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'");
  25.  
  26. //And we display the results
  27. while($result = mysql_fetch_array( $data ))
  28. {
  29. echo $result['Play'];
  30. echo " ";
  31. echo $result['Volume'];
  32. echo "<br>";
  33. echo $result['Opened'];
  34. echo "<br>";
  35. echo $result['Performances'];
  36. echo "<br>";
  37. echo "<br>";
  38. }
  39.  
  40. //This counts the number or results - and if there wasn't any it gives them a little message explaining that
  41. $anymatches=mysql_num_rows($data);
  42. if ($anymatches == 0)
  43. {
  44. echo "Sorry, but we can not find an entry to match your query<br><br>";
  45. }
  46.  
  47. //And we remind them what they searched for
  48. echo "<b>Searched For:</b> " .$find;
  49. }
  50. ?>
Aug 12 '07 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
Heya, lsmamadele. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

Try echoing mysql_error() right after you call mysql_query().
Aug 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.