title: Call SQL Server stored procedure with output parameter from PHP
body: <p>I am trying to execute a sql server stored procedure from php. Stored procedure returns a output value. I want that value in php to display in webpage.</p>
  
  <p>Everything works fine except the output value returns 0 in php.. but the row is getting inserted perfectly. the output value shows as 0. annoyed where I have made the mistake. Below is my php code</p>
  
  <pre><code>require('db.php');   
  
      $billno = "REF0001";  
      $retsno = 0.0;  
  
      $sp_name = "{call testinsert( ?, ? )}";
  
      $params = array(   
                       array($billno, SQLSRV_PARAM_IN),  
                       array($retsno, SQLSRV_PARAM_OUT)  
                     );  
  
      /* Execute the query. */  
      $stmt3 = sqlsrv_query( $conn, $sp_name, $params);  
      if( $stmt3 === false )  
      {  
           echo "Error in executing statement 3.\n";  
           die( print_r( sqlsrv_errors(), true));  
      }  
  
  
      echo "Inserted Retuern Sno for ".$billno." is ". $retsno. ".";  
  </code></pre>
  
  <p>and my stored procedure is</p>
  
  <pre><code>create procedure testinsert(@bill_no VARCHAR(20),@RetSno INT OUTPUT)
  as
  begin
      insert into testable values(@bill_no,GETDATE())
      set @RetSno = @@IDENTITY
      return
  end
  </code></pre>