Sending NULL data to date field instead of string


Hi there, I have been trying to resolve this issue for weeks now and finally admitted defeat!

When I insert or update a php form several fields can either be null or contain a date but my code is always reporting it as invalid date when inserting or updating.

The fields below ‘signedupdate’ & ‘DOB’ cpuld be NULL or a datevalue, the mysql table is set as Date | Default: NULL | Allow Null

$dateValue1 = is_null($rowData[’ signedupdate ‘]) ? ‘NULL’ : sprintf("’%s’", $rowData[’ signedupdate’]);
$dateValue2 = is_null($rowData[’ DOB ‘]) ? ‘NULL’ : sprintf("’%s’", $rowData[’ DOB’]);

$sql = sprintf(“UPDATE tbl_lead SET DOB = ‘%s’ , signedupdate = ‘%s’ WHERE client_id = %d;”, $rowData[’$dateValue2’], $rowData[’$dateValue1’]);

Has anyone any ideas what I can use to allow the form to send null data?


Not sure if you copied and pasted the code in, but there are spaces for all of them


You might want to check if the field is null, whitespace, or even set first.