sqlsrv_num_rows function.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
divxkorea
Forum Newbie
Posts: 2
Joined: Mon May 26, 2014 9:46 pm

sqlsrv_num_rows function.

Post 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?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: sqlsrv_num_rows function.

Post by Christopher »

You should check for an error and show the error message after the query to see if there is a problem occurring.
(#10850)
divxkorea
Forum Newbie
Posts: 2
Joined: Mon May 26, 2014 9:46 pm

Re: sqlsrv_num_rows function.

Post by divxkorea »

thx Christopher let me check the errroe message.
Post Reply