RE: [PHP-DB] variable with NULL value

2007-05-04 Thread Ford, Mike
On 03 May 2007 16:22, OKi98 wrote:

> Hi,
> 
> one more question.
> 
> Why the variable, that contains NULL value appears to be not
> set.

U -- because that's how it's defined??  (http://php.net/isset)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm


Re: [PHP-DB] variable with NULL value

2007-05-03 Thread Chris

James Gadrow wrote:

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.


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

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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] variable with NULL value

2007-05-03 Thread James Gadrow

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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php