Persistent warning: mysql_fetch_array() expects parameter 1 to be resource
<p>I have been trying to find out what's causing this error, but for some reason. It just won't show up!</p>

<p>It's been giving me this warning message:</p>

<blockquote>
  <p>Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\eis\usercp.inc.php on line 64</p>
</blockquote>

<p>I tried using <code>mysql_error();</code> but it didn't show anything.</p>

<p>Here's my code:</p>

<pre><code>&lt;?php
$firstname =  getuserfield('txtFname');
$lastname = getuserfield('txtLname');
echo 'Hello '.$firstname.' '.$lastname.'.&lt;br/&gt;';

$anotif = 0;
$dnotif = 0;
$anotif = $anotif + getuserfield('approved_notif');
$dnotif = $dnotif + getuserfield('disapproved_notif');
?&gt;
&lt;h3&gt;Notifications:&lt;/h3&gt;
Approved:&lt;?php if($anotif&lt;1){echo 0;} else { echo '&lt;a href="?anotif"&gt;'.$anotif.'&lt;/a&gt;';}?&gt;&lt;br/&gt;
&lt;?php 
if(isset($_GET['anotif'])) {
    $query = "SELECT * FROM hrf_leave WHERE empid = '$empid' AND formStatus = 1 AND checked = 0";
    $query_run = mysql_query($query) or die($query."&lt;br/&gt;&lt;br/&gt;".mysql_error());
    echo "&lt;table border=1&gt;
    &lt;tr&gt;
    &lt;th&gt;Type of Leave&lt;/th&gt;
    &lt;th&gt;Specific Reason&lt;/th&gt;
    &lt;th&gt;Date From&lt;/th&gt;
    &lt;th&gt;Date To&lt;/th&gt;
    &lt;th&gt;Number of Days&lt;/th&gt;
    &lt;/tr&gt;";
    echo "&lt;tr&gt;";
    while($record = mysql_fetch_array($query_run)){ // &lt;------- this is line 64
        $leave_id = $record['leave_id'];
        echo "&lt;td&gt;" . $record['type_of_leave'] . "&lt;/td&gt;";
        echo "&lt;td&gt;" . $record['specific_reason'] . "&lt;/td&gt;";
        echo "&lt;td&gt;" . $record['date_from'] . "&lt;/td&gt;";
        echo "&lt;td&gt;" . $record['date_to'] . "&lt;/td&gt;";
        echo "&lt;td&gt;" . $record['num_of_days'] . "&lt;/td&gt;";
        echo "&lt;/tr&gt;";
        $query = "UPDATE hrf_leave SET checked=1 WHERE leave_id = $leave_id";
        if($query_run = mysql_query($query)){ 
            $anotif = $anotif-1;
            $query = "UPDATE hrf_leave SET approved_notif=$anotif WHERE empid = $empid";
            if($query_run = mysql_query($query)){ 
                echo 'Recently approved requests';
            }
        }
    }
    echo "&lt;/table&gt;";
}
?&gt;
Disapproved:&lt;?php if($dnotif&lt;1){echo 0;} else { echo '&lt;a href="?dnotif"&gt;'.$dnotif.'&lt;/a&gt;&lt;br/&gt;';} ?&gt;
&lt;?php
if(isset($_GET['dnotif'])) {
    $query = "SELECT * FROM hrf_leave WHERE empid = '$empid' AND formStatus = 2 AND checked=0";
    $query_run = mysql_query($query);
    echo "&lt;table border=1&gt;
    &lt;tr&gt;
    &lt;th&gt;Type of Leave&lt;/th&gt;
    &lt;th&gt;Specific Reason&lt;/th&gt;
    &lt;th&gt;Date From&lt;/th&gt;
    &lt;th&gt;Date To&lt;/th&gt;
    &lt;th&gt;Number of Days&lt;/th&gt;
    &lt;/tr&gt;";
    echo "&lt;tr&gt;";
    while($record = mysql_fetch_array($query_run)){
        $leave_id = $record['leave_id'];
        echo "&lt;td&gt;" . $record['type_of_leave'] . "&lt;/td&gt;";
        echo "&lt;td&gt;" . $record['specific_reason'] . "&lt;/td&gt;";
        echo "&lt;td&gt;" . $record['date_from'] . "&lt;/td&gt;";
        echo "&lt;td&gt;" . $record['date_to'] . "&lt;/td&gt;";
        echo "&lt;td&gt;" . $record['num_of_days'] . "&lt;/td&gt;";
        echo "&lt;/tr&gt;";
        $query = "UPDATE hrf_leave SET checked=1 WHERE leave_id = $leave_id";
        if($query_run = mysql_query($query)){ 
            $dnotif = $dnotif-1;
            $query = "UPDATE hrf_leave SET disapproved_notif=$dnotif WHERE empid = $empid";
            if($query_run = mysql_query($query)){ 
                echo 'Recently disapproved requests';
            }
        }
    }
    echo "&lt;/table&gt;";
}
?&gt;
</code></pre>

<p>Anyway, I have been trying to output the leave forms whos checked field value = 0. Once seen, the system will set it to 1. Once the link is clicked, all the notification values for approved and disapproved will equal to zero.</p>

<p>This is my mini notification system. But I can't get it to work because of this error.. :/</p>
