Null Value Is Substituted By ''
If $Time is null, then in the query it is substituted by ''. As a result the query is incorrect. How to avoid this problem? $Time = strtotime($arrivals[$i]['time']); if ($Time != n
Solution 1:
If you want NULL in the query instead of '2013-...', you obviously have to do a little more.
if ($Time === null) {
$Time = 'NULL';
} else {
$Time = strftime("'%Y-%m-%d %H:%M:%S'", $Time);
// ^ note the quotes ^
}
$query = "INSERT INTO `Schedule` (`Time`) VALUES ($Time);";
// note: no quotes ^ ^
Solution 2:
Try this:
$query="INSERT INTO `Schedule` (`Time`) VALUES('".($Time==''?'null':$Time)."');";
Post a Comment for "Null Value Is Substituted By ''"