note 11932 added to function.count.php

From: Date: Tue, 13 Mar 2001 22:16:14 +0000
Subject: note 11932 added to function.count.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-12354@lists.php.net to get a copy of this message
The count function does not consider the situation where one might fire an SQL query which returns only one row ; and that row has only one column. For example... $sql = "select count(*) as cnt from afl_info"; $client_results = mssql_query($sql,$conn); $client_row = mssql_fetch_array($client_results); mssql_free_result($client_results); if ($client_row["cnt"] == 1) { .... in this case the query will always return 1 row, having one column; therefore the count function will return 1. however, in the documentation , it says that if the count fn returns 1, then it means that the variable (on which the count fn was used) is not a function. http://www.php.net/manual/en/function.count.php

« previous php.notes (#12354) next »