Page 1 of 1

Determining if a value is returned from a MySQL database

Posted: Tue Aug 05, 2003 3:26 am
by Nigel Moore
I originally posted this in the PHP-Normal forum, but since it relates to MySQL retreival, it may be better here. A number of posters on the PHP manual decry the empty() function based on their own usage, but I want to determine whether or not a string variable is returned from a database.

Am I correct in thinking that, for this purpose,

Code: Select all

if (empty($var)) {...
is the same as

Code: Select all

if (!$var) {...
and that, similarly,

Code: Select all

if (!empty($var)) {...
and

Code: Select all

if (!$var) {...
are the same? What are the advantages/disadvantages of using one approach over the other?

Cheers

Posted: Thu Aug 07, 2003 4:23 pm
by Nigel Moore
I'd like to thank you all for your responses here. I'm touched.

No, really I am.

Posted: Fri Aug 08, 2003 2:32 pm
by Crashin
Check out:

http://us2.php.net/manual/en/function.empty.php

and:

http://us2.php.net/manual/en/function.isset.php

And, remember...

Code: Select all

<?php
if (isset($sarchasm)) {
     echo "";
}
else {
     echo $replies;
}
?>
:D