title: Row count in PHP from MSSQL
body: <p>I am starting to learn PHP and will need to connect to SQL Server.  The web server I am using is Apache. My PHP below outputs the "Connection established" in the browser window okay but to make sure I am getting data too I included the code for getting a row count but for some reason the code around the row count doesn't appear to work but yet the code after the row count part outputs the "Results returned" to the browser.  I have tried changing the SELECT to a count using COUNT(Name) and also changed</p>
  
  <pre><code>$result = sqlsrv_query($conn, $query)
  </code></pre>
  
  <p>to</p>
  
  <pre><code>$result = sqlsrv_query($conn, $query, array(), array("Scrollable" =&gt; 
  'static'))
  </code></pre>
  
  <p>But neither has worked so far.  Why is the row count not working?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
   &lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;title&gt;Check SQL Server Connection&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
     &lt;?php
       $serverName = "IT90334\SQLEXPRESS";
       $connectionInfo = array('Database' =&gt; 'AdventureWorks');
       $conn = sqlsrv_connect($serverName, $connectionInfo);
  
       if ($conn) {
         echo "Connection Established.&lt;br /&gt;";
       } else {
         echo "Something went wrong while connecting to MSSQL.&lt;br /&gt;";
         die(print_r(sqlsrv_errors(), true));
       }
  
       $query = "SELECT Name FROM production.Location"
       $result = sqlsrv_query($conn, $query)
          or die('An error has occurred');
  
       $rowcount = sqlsrv_num_rows($result);
  
       if($rowcount === FALSE){
         echo "failure";
       }
       else {
         echo $rowcount;
       }
  
       if($result === FALSE){
         die(print_r(sqlsrv_errors(), true));
       }
       else {
         echo "Results returned. &lt;br /&gt;;
       }
  
       sqlsrv_close($conn);
  
    ?&gt;
    &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>