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
<?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