For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > May 2007 > Re: [PHP-DB] variable with NULL value









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] variable with NULL value
James Gadrow

2007-05-03, 6:57 pm

OKi98 wrote:
> Hi,
>
> one more question.
>
> Why the variable, that contains NULL value appears to be not set. When
> you try to echo it the php does not produce warning about using
> undefined variable.
>
> //$connection contains database connection handler
> $result=mysql_query("select NULL as value",$connection);
> $tmp=mysql_fetch_array($result);
> $foo=$tmp["value"];
> if (!isset($foo)) echo("\$foo is not set but does not produce warning
> -$foo-");
>
> OKi98
>

Someone correct me if I'm wrong but it appears that you should be using
if(!isset($tmp["value"]) before assigning to $foo if you want to ensure
that $foo will, indeed, be set.

--
Thanks,

Jim
Chris

2007-05-03, 9:57 pm

James Gadrow wrote:
> OKi98 wrote:
> Someone correct me if I'm wrong but it appears that you should be using
> if(!isset($tmp["value"]) before assigning to $foo if you want to ensure
> that $foo will, indeed, be set.


Yeh - you need to check before you do the assignment.

--
Postgresql & php tutorials
http://www.designmagick.com/
Carso

2007-05-12, 4:19 am

Katie Holmes touching her boobs!
http://Katie-Holmes-touching-her-bo...hp?movie=726648
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com