mschrank99 Posted November 9, 2006 Share Posted November 9, 2006 $result... (yadda yadda, postgresql query);$row = pg_fetch_all($result);$count = count($row);The strange thing is, $count is never = 0 when there is nothing to be found. It always returns at least a value of 1. Why is this happening?Thanks,Matt Quote Link to comment Share on other sites More sharing options...
btherl Posted November 9, 2006 Share Posted November 9, 2006 If there's nothing to be found, then $row will be set to false. The value false consists of one item, so counting it will always give you one.Instead, use[code]if ($row === false) print "Finished fetching data from database\n";[/code] Quote Link to comment Share on other sites More sharing options...
mschrank99 Posted November 9, 2006 Author Share Posted November 9, 2006 Thank you very much- I used the following code:if ($family_accounts != FALSE) { $count = count($family_accounts);}else { $count = 0;} Quote Link to comment Share on other sites More sharing options...
Orio Posted November 9, 2006 Share Posted November 9, 2006 If you want a shorter version:$count = (!family_accounts) ? 0 : count($family_accounts);Orio. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.