Simple Question -> empty() or is_null()
Posted: Fri Sep 01, 2006 2:56 pm
When you query the database and retrieve records that are both NOT NULL and of NULL type, and you want to determine if one of the column's value you retrieved is NULL or something in it like a string, are you supposed to use is_null() or empty() to check the column?
For instance,
- OR -
Of course the reason I want to check is because 'lastName' is setup like so in MySQL:
lastName VARCHAR(30) DEFAULT NULL
..and if the user decides not to fill out his last name in the form, then it simply INSERT's a value of NULL for that column in the INSERT query.
Thanks for your help on this matter.
For instance,
Code: Select all
if (!is_null($row['lastName'])) echo $row['lastName'];Code: Select all
if (!empty($row['lastName'])) echo $row['lastName'];lastName VARCHAR(30) DEFAULT NULL
..and if the user decides not to fill out his last name in the form, then it simply INSERT's a value of NULL for that column in the INSERT query.
Thanks for your help on this matter.