'sqlsrv_num_rows resule Warning: sqlsrv_num_rows() expects parameter 1 to be resource, boolean give [duplicate]

$results = sqlsrv_query($dbconn, $query2, array(), array('Scrollable' => 'static'));
if (sqlsrv_num_rows($results) >= 2) {
    $query3 = "UPDATE ClanDb.dbo.CL SET RegiDate =
    '$today', Cpoint = (SELECT SUM(Point) FROM
    SodDb.dbo.Sod2Clan$yyMM WHERE SodDb.dbo.Sod2Clan$yyMM.

How do i fix this one?

Warning: sqlsrv_num_rows() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\Clan\sod2.php on line 42



Solution 1:[1]

sqlsrv_query returns a statement resource on success and FALSE if an error occurred.

So $results is probably FALSE. Check your $results, you probably do not have db connection established or $query2 is not good.

Check documentation for sqlsrv_query http://php.net/manual/en/function.sqlsrv-query.php, and then for sqlsrv_num_rows.

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 Stasa Stanisic