title: Not getting anything back from sqlsrv_num_rows
body: <p>I'm trying pull back data from MS SQL via a php page. I have got a valid connection, and am trying a simple SELECT * FROM MyTable but sqlsrv_num_rows is just blank no matter what I do!!!</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    function connect() {
  
      $serverName = DB_HOST; //serverName\instanceName
      $connectionInfo = array( "Database"=&gt;DB_NAME, "UID"=&gt;DB_USER, "PWD"=&gt;DB_PASSWORD);
      $this-&gt;connection = sqlsrv_connect( $serverName, $connectionInfo);
      sqlsrv_connect( $serverName, $connectionInfo);
  
  
      if( $this-&gt;connection ) {
           echo "&lt;br&gt;Connection established.&lt;br /&gt;";
      }else{
           echo "&lt;br&gt;Connection could not be established.&lt;br /&gt;";
           die( print_r( sqlsrv_errors(), true));
      }       
  
  
  }
  </code></pre>
  
  <p>The echo for Connection established is working so all AOK there!</p>
  
  <p>Now when I do a simple query:</p>
  
  <pre><code>    function query($sql) {
      if ($this-&gt;debug) {
          echo $sql . "&lt;br /&gt;";
      }       
      $this-&gt;sql = $sql;
      $this-&gt;recordset = sqlsrv_query($this-&gt;connection, $sql);
  
      if (!$this-&gt;recordset) {
          die('&lt;br&gt;&lt;br&gt;Invalid query :&lt;br&gt;&lt;br&gt;&lt;bold&gt;' . $this-&gt;sql . '&lt;/bold&gt;&lt;br&gt;&lt;br&gt;' . sqlsrv_errors());
      }
  
      echo "&lt;br&gt;rows = " . sqlsrv_num_rows($this-&gt;recordset);
  </code></pre>
  
  <p>I get absolutely nothing from the above echo? Any reason why? Or can you suggest a new echo I can try to debug this?</p>
  
  <p>All my code in my DB class is converted from mysql so there may be a few bits wrong that is doing the damage!</p>
  
  <p>I've even tried a super simple version, all the code together and it's still blank/false:</p>
  
  <pre><code>    $server = DB_HOST;
  $conn = sqlsrv_connect( $server, array( "Database"=&gt;DB_NAME, "UID"=&gt;DB_USER, "PWD"=&gt;DB_PASSWORD) );
  $stmt = sqlsrv_query( $conn, "SELECT * FROM MyTable");
  $row_count = sqlsrv_num_rows($stmt);
  echo "&lt;br&gt;row count = " . $row_count;
  if ($row_count === false)
    echo "\nerror\n";
  else if ($row_count &gt;=0)
    echo "\n$row_count\n";
    die;
  </code></pre>