At 10:14 AM +0200 2000-03-17, Richard Ellerbrock wrote:
> >Richard Ellerbrock wrote:
>
>I did some more testing and have found what the problem is. I added
>some error checking and no errors are returned. The problem has to
>do with the way php compares an array and the way php fills an
>array if a NULL value is found in the database.
>
>If I do a
>
>$row = mysql_fetch_array($result)
>
>and then do a count($row) to count the number of elements in the
>array returned, 0 is returned. Thus if a null value is found, an
>empty array is returned causing this test
>
>while($row = mysql_fetch_array($result))
>
>to fail and no records are displayed. I changed the logic to use
>mysql_num_rows(). So my new logic is
>
>$rowcnt=mysql_num_rows($result);
>for ($x=0; $x < $rowcnt; $x++) {
> $row = mysql_fetch_array($result);
> echo "Display results here";
>}
>
>So the bug is not with mysql. It maybe has to do with the way php
>handles NULL values returned from a database. Do you think this is a
>bug in php?
It's certainly been behavior that's been the cause of some controversy,
but that is how PHP behaves. It still behaves that way in PHP 4; I
doubt if it's likely to change. So for result sets that may contain
rows that consistent entirely of NULL values, you're best off using
your modified strategy.
--
Paul DuBois, paul@stripped