Warning: sqlsrv_num_rows() expects parameter 1 to be resource, boolean given
<p>This warning can happen for many different reasons, however, I think that my problem here is that the table <code>APPT</code> is empty/and doesn't contain any <code>row</code> with the <code>t_schedule_id</code>.  I read every question that may already have my answer, and all answers stated the same thing &quot;your SQL query is not being successful and a FALSE boolean value is being returneds &quot;..So yes, I know that the query is returning false because there is 0 rows with the <code>t_schedule_id</code>  and that is my point, I want my function to return the <code>int</code> <code>0</code> when there is <code>0</code> row with <code>t_schedule_id</code></p>
<p>function.php</p>
<pre><code>function get_appt($schedule_id,$conn){

    $query = &quot;select t_schedule_id as t_schedule_id from [dbo].[APPT] where t_schedule_id = .$schedule_id.; &quot;;

    $stmt = sqlsrv_query($conn,$query);

    $row_count = sqlsrv_num_rows($stmt);

    if ($row_count === false){
       return 0;
    }else{
       return $row_count;
    }
 }
</code></pre>
<p>application.php</p>
<pre><code>$get_appt = get_appt(1, $conn);
echo $get_appt;
</code></pre>
<p>So, my question is how can I stop getting this <code>warning</code>, no matter if the table return <code>0</code> If is <code>0</code> is <code>0</code> if is a <code>number &gt; 0</code> then return that number.</p>
<p>PS: I know there is no error in my query name such as <code>table name, column name etc ...</code>  And, when I <code>echo $get_appt;</code> I get the value <code>0</code> but also the warning</p>
<blockquote>
<p>Warning: sqlsrv_num_rows() expects parameter 1 to be resource, boolean given in line 220</p>
</blockquote>
<p>And this is line 220 <code>$row_count = sqlsrv_num_rows($stmt);</code></p>