我有一個名爲'updated_at'的日期時間數據類型的列在mysql表中,我想要當前的日期和時間。我試圖從php插入一個記錄到mysql表中,如如下:從php插入日期時間值到MySQL
mysql_query("INSERT INTO my_table (service_name,service_status,service_comment,user_name,updated_at) VALUES($service_name,$service_status,$service_comment,$user_name,$updated_at) ")
$的updated_at定義如下:
$updated_at = date("D, d M Y H:i:s O");
但插入不會發生。任何方法來解決這個問題?
請幫助 謝謝
日期時間字段格式是英里遠 「d,d MYH:I:S 0」 一個 – 2010-09-09 09:03:29
然而,這不是唯一的錯誤... – 2010-09-09 09:04:25
@James除了@Col所說的,你需要用引號將值包裝起來。 ''updated_at'' ... – 2010-09-09 09:05:58