Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in [duplicate]

Possible Duplicate:
PHP: Warning: sort() expects parameter 1 to be array, resource given

Please help,

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); 
echo $result2;
        $replace =  str_replace(", "," | ", $result2);
    while ($line = mysql_fetch_array($result2, MYSQL_BOTH))

Solution 1:

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.

Solution 2:

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).

Solution 3:

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..