14

I get following Error:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in......

Here is my Query:

$query = "SELECT ListNumber FROM residential"; 
$result1 = mysql_query($query); 
if (mysql_num_rows($result1) >10){ 
    $difference = mysql_num_rows($result1) - 10; 
    $myQuery = "SELECT * FROM `residential` ORDER BY `id` LIMIT 10,". $difference; 
    $result2 = mysql_query($myQuery); 
    while ($line = mysql_fetch_array($result2, MYSQL_BOTH))
Dharman
  • 30,962
  • 25
  • 85
  • 135
Corrie
  • 155
  • 2
  • 3
  • 9

4 Answers4

40

Your query ($myQuery) is failing and therefore not producing a query resource, but instead producing FALSE.

To reveal what your dynamically generated query looks like and reveal the errors, try this:

$result2 = mysql_query($myQuery) or die($myQuery."<br/><br/>".mysql_error());

The error message will guide you to the solution, which from your comment below is related to using ORDER BY on a field that doesn't exist in the table you're SELECTing from.

Codecraft
  • 8,291
  • 4
  • 28
  • 45
1

mysql_fetch_array() expects parameter 1 to be resource boolean given in php error on server if you get this error : please select all privileges on your server. u will get the answer..

Taryn
  • 242,637
  • 56
  • 362
  • 405
kavita
  • 11
  • 1
1

The code you have posted doesn't include a call to mysql_fetch_array(). However, what is most likely going wrong is that you are issuing a query that returns an error message, in which case the return value from the query function is false, and attempting to call mysql_fetch_array() on it doesn't work (because boolean false is not a mysql result object).

Hammerite
  • 21,755
  • 6
  • 70
  • 91
-1

This error comes when there is error in your query syntax check field names table name, mean check your query syntax.

Taryn
  • 242,637
  • 56
  • 362
  • 405
ukpatel
  • 21