Determining if a value is returned from a MySQL database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Nigel Moore
Forum Newbie
Posts: 3
Joined: Mon Aug 04, 2003 4:16 pm

Determining if a value is returned from a MySQL database

Post 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
Nigel Moore
Forum Newbie
Posts: 3
Joined: Mon Aug 04, 2003 4:16 pm

Post by Nigel Moore »

I'd like to thank you all for your responses here. I'm touched.

No, really I am.
User avatar
Crashin
Forum Contributor
Posts: 223
Joined: Mon May 06, 2002 3:42 pm
Location: Colorado

Post 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
Post Reply