Re: syntax question
| From: | Jeff Bluemel | Date: | Mon, 30 Sep 2002 06:14:27 +0000 |
| Subject: | Re: syntax question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-118157@lists.php.net to get a copy of this message | ||
let me be more specific...
if a field value is null how do I test for it in the result set, or the
array?
here's a real live example... I'm working with prepaid phone cards, and if
a card has not expired yet then the field zombie_date will be null.
so - when I do the mysql_fetch_assoc ($sql) what value will the field
contain if the resulting recordset was a null? instead of leaving that
table space blank I would like to populate it with "Not Expired" or
something like that. (I have a lot of scenario's where I would like to use
that).
"Chris Shiflett" <shiflett@php.net> wrote in message
news:3D97E149.5070009@php.net...
> Justin French wrote:
>
> >on 30/09/02 2:44 PM, Jeff Bluemel (jeff@domintcom.com) wrote:
> >
> >
> >>how to I test for a null value?
> >>
> >>
> >empty()? isset()? if($var == "")? if($var == "NULL")?? have a look
> >in
> >the php manual for string functions, and comparison operators
> >
>
> I think he maybe meant testing for null values in SQL.
>
> If this is true, there is the null keyword: "is null" and "is not null".
>
> select * from table_name where column_name is not null
>
> This selects all rows from a table where the data in column column_name
> is not null. Be careful with this, as it actually tests for null and not
> an empty string, for example. If you want to test whether a value is
> null once you have assigned it to a PHP variable, you can use one of
> Justin's suggestions.
>
> In addition, PHP has null as well.
>
> Happy hacking.
>
> Chris
>