I am fairly new to SQL-Server and PHP, but I'm trying to get the total number of rows in my table with PHP.
This is the code I am using, it connects just fine, however it won't print the number of rows:
<?php
$serverName = "SERVER1\SQLEXPRESS";
$connectionInfo = array( "Database"=>"petitionlist");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
?>
<b>Error: </b>Could not connect to the server database.
<?php
die( print_r( sqlsrv_errors(), true));
}
$tsql = "Select Count(*) from SignatureTable";
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false )
{
?>
<b>Error: </b>
<?php
die( print_r( sqlsrv_errors(), true));
}
?>
<b>Result:</b><br />
<?php
print_r(sqlsrv_fetch_object($stmt));
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>
If I execute the "Select Count(*) from SignatureTable" command on the SQL Server Studio it returns the correct number. So It's not my server, it's my code.