Reply to Re: Test for NULL values in array/sql database?

Your name:

Reply:


Posted by BearItAll on 06/21/05 11:24

On Tue, 21 Jun 2005 00:03:26 -0700, madsgormlarsen wrote:

> Hi
>
> I need to test a field(colum) in a SQL database for for NULL values, and
> have done so in this way.
>
> $query = "SELECT j FROM Andersen";
> $result = mysql_query($query, $link_id); $query_data =
> mysql_fetch_array($result); if (array_sum($query_data)==0)
> {
> echo "er nul";
> }
> }
>
>
>
> Does "mysql_fetch_array($result)" change the NULL values to zero values?
> And is there a better way of doing it.

It isn't really wise to assume NULL is equal to zero if they is a
possibility of your sql/script being ported to another database.

NULL is best thought of as an object rather than a value, so in your sql
you would test using 'is'.

Ex,

$query = "SELECT j FROM Andersen WHERE column IS NULL";

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация