Probeer dit:
$query = "INSERT INTO table (column_s1, column_s2, column_d1, column_d2)
VALUES ('$string1', '$string2', " . ($date1==NULL ? "NULL" : "'$date1'") . ", " . ($date2==NULL ? "NULL" : "'$date2'") . ");";
dus als u dit bijvoorbeeld in de query invoert:
$string1 = "s1";
$string2 = "s2";
$date1 = NULL;
$date2 = NULL;
resultaat zou moeten zijn:
INSERT INTO table (column_s1, column_s2, column_d1, column_d2) VALUES ('s1', 's2', NULL, NULL);