note 59929 deleted from function.count by googleguy
| From: | googleguy@php.net | Date: | Mon, 17 Sep 2012 00:17:06 +0000 |
| Subject: | note 59929 deleted from function.count by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190838@lists.php.net to get a copy of this message | ||
Note Submitter: Scorch at netpix dot com
----
Be careful of recasting your variables, especially with database array returns:
<?php
$res = mysql_query("select * from blah") // a query that returns an empty set
$row = mysql_fetch_array($res); // get's 0 since there's no return
echo count($row); // echos 1 - since $row is not an array
echo $row[0]; // echos "", but casts $row as an array?
echo count($row); // echos 0 now
?>