i have a column in my database for the date a new record was added, it's set with the following code:
$dateset = date("Y-m-d");
$q = "INSERT INTO appts (date_set) VALUES ('$dateset')";
this is working about 80% of the time, is there any reason that randomly it will add the date as "0000-00-00"?
You should check type of field 'date_set'.
$dateset = date("Y-m-d");
$dateset = date("Y-m-d H:i:s"); //It is correct, but database push after time 00:00:00 (but it depends on the settings of the database) //$dateset = date("Y-m-d");
$dateset = time();
Try use sql:
$q = "INSERT INTO appts (date_set) VALUES (NOW())";
is there any reason that randomly it will add the date as "0000-00-00"?
No.
Either $dateset
populated some other way or value got updated to 0's later on.
I think it would the best decision to use
$q = "INSERT INTO appts (date_set) VALUES (NOW())";