可能重複:
illegal 0000-00-00 00:00:00 timestamp being sent by php to mysql using codeigniterSQL日期字段顯示爲0的
我想時間戳和日期/時間的組合查詢,但在查詢運行它加載0000-00-00 00:00:00
進入日期字段。 查詢:
$link = mysqli_connect("$server", "$user", "$pass", "$webdb");
$title = mysqli_real_escape_string($link, (string) $_POST['title']);
$content = mysqli_real_escape_string($link, (string) $_POST['content']);
$query = "INSERT INTO `blog` (`title`, `content`, `posted_by`, `published`, `profile_pic`, `date`)
VALUES ('$title', '$content','$display_name', '1', '$profile_pic', 'getdate()')";
mysqli_query($link, $query);
mysqli_close($link);
有沒有人看到我在做什麼錯?提前致謝。
謝謝;作爲臨時修復,我設置了一個變量$ d = date('M/d/Y')並在查詢中插入$ d;你會說遠離那個嗎? –
@MorganGreen你正在使用'TIMESTAMP','date('M/d/Y')'只是返回日期,所以你還需要使用時間 –
保持務實。這不是一個優雅的解決方案,但如果它有效,爲什麼不呢? – nalply