我有以下代碼:mysql,日期輸入全爲0?
$radate = date('Y-d-m h:i:s');
echo $radate;
foreach($_POST['member'] as $member)
{
mysql_query("INSERT INTO attend (UserName, rDate) values('$member', '$radate')");
mysql_query("UPDATE users set rAttend=(rAttend+1) where UserName='$member'");
}
mysql_query("INSERT INTO raids (rDate) value('$radate')");
mysql_query("UPDATE users SET rTotal=(rTotal+1)");
mysql_close();
?>
目前回波是打印: 2011-14-08九點47分17秒
但是,當我做診斷這樣的:
$result_id = mysql_query('SELECT * from raids');
if($result_id)
{
$results = array();
while($row = mysql_fetch_assoc($result_id))
{
$results[] = $row;
}
echo '<pre>';
print_r($results);
echo '</pre>';
}
else
echo mysql_error();
我得到這個作爲輸出:
Array
(
[0] => Array
(
[raidID] => 1
[rDate] => 0000-00-00 00:00:00
)
[1] => Array
(
[raidID] => 2
[rDate] => 0000-00-00 00:00:00
)
[2] => Array
(
[raidID] => 3
[rDate] => 0000-00-00 00:00:00
)
[3] => Array
(
[raidID] => 4
[rDate] => 0000-00-00 00:00:00
)
)
所以,以更簡潔的方式,插入時間我做錯了什麼?
謝謝你了。儘管如此,這些值都是從數據庫本身生成的,並且不需要轉義,但我認爲它不會受到傷害。也爲此感謝。 – HunderingThooves