469,964 Members | 1,513 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

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

123 100+
how can i fix these error and what does it mean
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in C:\wamp\www\test_php\log\search\result.php on line 8

Expand|Select|Wrap|Line Numbers
  1. <?php
  3. @mysql_connect('localhost','user2','point')or die('could not connect');
  4. @mysql_select_db('files') or die('could not select database');
  6. $term = $_GET['term'];
  7. $sql = mysql_query("SELECT * FROM user WHERE Fname LIKE %term%");
  8. while ($row = mysql_fetch_array($sql))
  9. {
  10. echo 'Fname : '.$row ['Fname'];
  11. echo '<br/>Lname :'.$row ['Lname'];
  12. echo '<br/>Address : '.$row ['Address'];
  13. echo '<br/>phone no: '.$row ['phone no'];
  14. echo '<br/>Email: '.$row ['Email'];
  15. echo '<br/><br/>';
  16. }
  17. ?>
Dec 19 '08 #1
4 1599
When you have a mysql error, you can output the error by echoing mysql_error() after the query has been sent.

Expand|Select|Wrap|Line Numbers
  1. $sql = mysql_query("SELECT * FROM user WHERE Fname LIKE '%term%'");
  2. if(!$sql)
  3. echo mysql_error();
In your query you must put %term% between quotes.

Expand|Select|Wrap|Line Numbers
  1. $sql = mysql_query("SELECT * FROM user WHERE Fname LIKE '%term%' ");
Dec 19 '08 #2
8,652 Expert Mod 8TB
actually, what is %term% (or did you mean $term or %$term%)?
Dec 19 '08 #3
1,584 Expert 1GB
Hi Simon,
I changed the original thread title (how can i fix this error) with the existing one.
while posting threads there are some rules/guidelines that everybody should read and follow.Please be good enough to have a look here. good luck.
Posting Guidelines


The meaning of that error is, there is no "result set" after executing that query. may be your SQL statement is in correct.
Dec 20 '08 #4
6,050 Expert 4TB
You get this because your query is returning no results. You should check using mysql_num_rows(), and, as mentioned before, it is very good practice to use the mysql_error() function on any query you do.

Dec 20 '08 #5

Post your reply

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

Similar topics

1 post views Thread by myaashik | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.