assigning NULL to a variable
| From: | Andy B | Date: | Tue, 06 Apr 2004 00:30:45 +0000 |
| Subject: | assigning NULL to a variable | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-182430@lists.php.net to get a copy of this message | ||
how would you assign NULL to a variable if its original value is ""? otherwise leave it
with its value...
the form im working on has a date field called "date" on the form itself. that
"date" will get turned into $_SESSION[add][date] on the next page...
i want it so if the person filling out the form didnt leave a date (left date field blank) then it
should be NULL so the mysql table will insert the current date...
so far i have this code:
if(empty($_SESSION['add']['date'])){
$_SESSION['add']['date']=NULL//or should it = FALSE??
}
//if its already filled do nothing else to it
is there a better way to do this than this way?