I'm getting a strange error when attempting to return the results of a working sqlsrv_query function call.
I have set up:
function test($someinput, &$someoutput)
{
//set up $dbc and $dbcOptions
//generate tsql
$params = array();
$stmt = sqlsrv_query($dbc, $tsql, $params, $dbcOptions);
$someoutput = $stmt;
return $stmt;
}
$outputvar;
$results = test($inputvar, $outputvar);
//---ERROR being thrown here
$rows = sqlsrv_num_rows($results);
//$rows2 = sqlsrv_num_rows($outputvar);
//---ERROR being thrown here
In both lines (doesn't matter which I use), I'm getting an error in my php-errors.log
file saying
PHP Warning: sqlsrv_num_rows(): 2 is not a valid ss_sqlsrv_stmt resource in
E:\inetpub\wwwroot\directory\searchtest.php on line 58
which searchtest.php
is the file I'm working on and line 58 is where I have the error-producing code.
Why can I not pass query results from a function like this?