Page 1 of 1

sqlsrv_num_rows function.

Posted: Mon May 26, 2014 9:53 pm
by divxkorea
Hi All,

Now I'm working on PHP+MSSQL.

So, I will use to get rows from database server.

And I'm typing on this code.

Code: Select all

<?php
$server = "host name";
$connectionInfo = array( "Database"=>"databasename", "UID"=>"id", "PWD"=>"password" );
$conn = sqlsrv_connect( $server, $connectionInfo );

$sql = "{call dbo.procedurename}";
$params = array();
$options =  array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$stmt = sqlsrv_query( $conn, $sql , $params, $options );

$row_count = sqlsrv_num_rows($stmt);
   
if ($row_count === false)
   echo "Error in retrieveing row count.";
else
   echo $row_count;
?>
But I got the 0 rows.

Why did I get 0 rows?

Re: sqlsrv_num_rows function.

Posted: Tue May 27, 2014 12:07 pm
by Christopher
You should check for an error and show the error message after the query to see if there is a problem occurring.

Re: sqlsrv_num_rows function.

Posted: Tue May 27, 2014 7:14 pm
by divxkorea
thx Christopher let me check the errroe message.