Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is wrong with the way I use sqlsrv_num_rows() in the following PHP script?

Status
Not open for further replies.

VirConti

Programmer
Mar 11, 2016
1
PH
I ran the following PHP script:

<?php
$serverName = "TABLET-0LJ29BE9\sqlexpress";
$connectionInfo = array( "Database"=>"MasterDB", "UID"=>"sa", "PWD"=>"noabrir" );
$conn=sqlsrv_connect( $serverName, $connectionInfo );

if( $conn )
{
echo "Connection established.<br />";
}
else
{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}

$sql="SELECT * FROM PROJECT";

$rs_PROJECT = sqlsrv_query( $conn, $sql );
if( $rs_PROJECT === false )
{
die( print_r( sqlsrv_errors(), true ));
}
else
echo "sqlsrv_query is successful."."<br>";

$count_rs_PROJECT=sqlsrv_num_rows( $rs_PROJECT );

if ($count_rs_PROJECT === false)
echo "Error in retrieveing row count.";
else
echo "count_rs_PROJECT=".$count_rs_PROJECT."<br>";

sqlsrv_free_stmt( $rs_PROJECT);
sqlsrv_close( $conn);
?>

Then I got the following output:

"Connection established.
sqlsrv_query is successful.
Error in retrieveing row count."

Kindly help me find what is wrong with the way I use sqlsrv_num_rows() in the above PHP script

Thank you.


Virgilio Conti
Philippines
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top