I have a time (H:i:s format), but not a date, so I call:
$dateFormat = 'Y-m-d H:i:s';
$value4 = date($dateFormat, strtotime($_POST['start_time']));
$value5 = date($dateFormat, strtotime($_POST['finish_time']));
Then I call the sql function:
$sql = "INSERT INTO times (site_id, crew_leader_id, service_number, start_time, finish_time,
deicer_quantity, salt_quantity)
VALUES ($value1, $value2, $value3, $value4, $value5, $value6, $value7)";
I get the following error:
Error: INSERT INTO times (site_id, crew_leader_id, service_number, start_time, finish_time, deicer_quantity, salt_quantity) VALUES (3, 1, 1, 2016-11-06 15:00:00, 2016-11-06 15:15:00, 0, 0)
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '15:00:00, 2016-11-06 15:15:00, 0, 0)' at line 3
The DateTime is in the correct mysql format, but won't go into the DB. Any ideas as to why? I'm running the latest php and mysql. Alternatively, if I try convert to a DateTime in mysql from a datetime string via UNIX_TIMESTAMP('datetimestring'), it fills the table with 0000-00-00 00:00:00. What the heck am I doing wrong??
-thanks in advance!