'sqlsrv_num_rows() expects parameter 1 to be resource, boolean given
Having an issue with sqlsrv_query
. This is the error I get:
PHP Warning: sqlsrv_num_rows() expects parameter 1 to be resource, boolean given
Here is the relevant code:
$tsql = "SELECT * FROM customers";
$stmt = sqlsrv_query($conn, $tsql, array(), array("Scrollable" => SQLSRV_CURSOR_STATIC));
$recordcount = sqlsrv_num_rows($stmt);
Solution 1:[1]
The documentation on sqlsrv_query()
has everything you need to know.
Return Values
Returns a statement resource on success and FALSE if an error occurred.
$stmt = sqlsrv_query( $conn, $sql, $params);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Community |