From: Steve D. <sd...@ne...> - 2004-03-25 08:30:41
|
> if ($var == '') checks for an empty string (which is e.g.an empty form > variable) > > if ($var == NULL) checks for NULL, check this > http://php.oregonstate.edu/manual/en/language.types.null.php I was afraid you were going to say that ... in both cases, it's returning true, even though when I go in the database and manually set the field to NULL or '' and then select on that same criteria, it pulls it up okay. As far as I can tell, when pulling any field out of sqlite that is NULL, php sets the variable to '' Ill have to try it on another database and see if that's the case there as well. $db = sqlite_open('steve.sqlite', 0666, $sqliteerror) or die($sqliteerror); $sql = "SELECT * FROM table WHERE some_field = NULL"; $res = sqlite_query($db, $sql); and print_r($row1=sqlite_fetch_array($res)); or while($row = sqlite_fetch_array($res)) { $nr_fields = count($row); for ($i=0; $i<$num_fields; $i++) { if($row[$i] == NULL && $row[$i] != '') { print "<i>NULL</i>\n"; } elseif($row[$i] == '') { print "empty\n"; } else { print "$row[$i]\n"; } } } Steve |