要将NULL传递给MysqL,只需执行此操作。
INSERT INTO table (field,field2) VALUES (NULL,3)
因此,在您的代码中,检查if $intLat, $intLng
是empty
,如果是,请使用NULL
代替'$intLat'
或'$intLng'
。
$intLat = !empty($intLat) ? "'$intLat'" : "NULL";
$intLng = !empty($intLng) ? "'$intLng'" : "NULL";
$query = "INSERT INTO data (notes, id, filesUploaded, lat, lng, intLat, intLng)
VALUES ('$notes', '$id', TRIM('$imageUploaded'), '$lat', '$long',
$intLat, $intLng)";