Error Putting a DateTime from php to mysql db? -
this question has answer here:
i have time (h:i:s format), not date, call:
$dateformat = 'y-m-d h:i:s'; $value4 = date($dateformat, strtotime($_post['start_time'])); $value5 = date($dateformat, strtotime($_post['finish_time']));
then call sql function:
$sql = "insert 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 following error:
error: insert 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) have error in sql syntax; check manual corresponds mariadb server version right syntax use near '15:00:00, 2016-11-06 15:15:00, 0, 0)' @ line 3
the datetime in correct mysql format, won't go db. ideas why? i'm running latest php , mysql. alternatively, if try convert datetime in mysql datetime string via unix_timestamp('datetimestring'), fills table 0000-00-00 00:00:00. heck doing wrong??
-thanks in advance!
Comments
Post a Comment