Answer the question
In order to leave comments, you need to log in
Who can explain the "weird" behavior in MySQL and help fix the error?
The table has a field of type DATETIME and it can be NULL.
When the user does not fill in the corresponding field in the HTML form, naturally its value will be an empty string. The following query is made like:
UPDATE `tbl` SET ...bla bla bla... `d` = DATE(:date)
SELECT DATE('')
Answer the question
In order to leave comments, you need to log in
Replaced with:
UPDATE `tbl` SET ...bla bla bla... `d` = IF(:date, DATE(:date), NULL)
Check the value before inserting, and if it's empty explicitly set $date=0; `d`='".$date."'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question