PHP‎ > ‎

Execute a SQL Server stored procedure with PHP and capture return parameter

Apparently, you can't use an ADO connection to SQL Server.   You have to use PHP's built in sqlsrv_connection function to create the connection.

$serverName = "myserver\SQLEXPRESS";
$connectionInfo = array( "Database"=>"mydatabase", "UID"=>"myuser", "PWD"=>"mypassword","ConnectionPooling" => "1","MultipleActiveResultSets"=>'0');
$conn = sqlsrv_connect( $serverName, $connectionInfo );
if( $conn === false ) {
    die( print_r( sqlsrv_errors(), true));
$stmt = "{ CALL sp_PasswordHash (?,?)}"; //calling stored procedure with single input parameter and 1 output parameter
$psw='mypassword'; //search string
$params = array( 
                 array($psw, SQLSRV_PARAM_IN),
                 array($hash, SQLSRV_PARAM_OUT)
$result = sqlsrv_query( $conn, $stmt,$params);
echo "My hash is ".$hash;
sqlsrv_close( $conn);

NOTE:   you initially set the output parameter (in this case $hash) to a value that is representative of what the stored procedure return parameter will contain.