The DEFAULT
value of a column in MySql is used only if it isn't provided a value for that column.
So if you
INSERT INTO contactinfo (name, email, subject, date, comments)
VALUES ('$name', '$email', '$subject', '', '$comments')
You are not using the DEFAULT
value for the column date
, but you are providing an empty string, so you get an error, because you can't store an empty string in a DATETIME
column.
The same thing apply if you use NULL
, because again NULL
is a value.
However, if you remove the column from the list of the column you are inserting, MySql will use the DEFAULT
value specified for that column (or the data type default one)