I have an HTML form with an input field (type="date") and a mysql DB with a column with datatype "date" that accepts null when I do the query directly in phpmyadmin.
Also when I select a date in my html form (using browser default date picker) the query runs correctly. But when I leave the mentioned input blank, the following error is shown "Incorrect date value: '' for column 'received_date'.
Any help to get rid of this issue is appreciated.
Here are the sql and DB/Table schema:
CREATE TABLE customer.tbl1 ( id INT NOT NULL AUTO_INCREMENT , usrname
VARCHAR(32) NOT NULL , received_date DATE NULL DEFAULT NULL , PRIMARY
KEY (id)) ENGINE = MyISAM;
$sql = "INSERT INTO tbl1 (usrname, received_date) VALUES ('$usrname',
'$received_date')";
if (empty($_post['date']))? NULL: $_POST['date']and then do querySELECTand here you are providingINSERT. very confusing. Please add HTML+CODE in your question to clarify your problem.