我已经阅读了许多关于当前时间戳的帖子,并尝试了很多提供的解决方案,但是他们没有解决我的问题。我需要将当前时间戳添加到数据库中。我认为我的代码可能是其他解决方案无法正常工作的原因。其他一切都完美发布。时间戳记给我所有的“0”,我尝试的其他解决方案给了我一个“第6行错误”。当前时间戳
这里是我当前的代码
<?php
$con = mysql_connect("mysql","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
/* Prevent duplicate submissions */
if (isset($_COOKIE['FormSubmitted']))
{
show_error('You may only submit this form once per session!');
}
mysql_select_db("seller", $con);
$sql="INSERT INTO listing (name, email, website, url, dropdown, price, date, visitors, income, host, description)
VALUES
('$_POST[name]', '$_POST[email]', '$_POST[website]', '$_POST[url]', '$_POST [dropdown]', '$_POST[price]', '$_POST[date]','$_POST[visitors]', '$_POST[income]', '$_POST[host]', '$_POST[description]', 'CURRENT_TIMESTAMP[subdate]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Thank you for listing with us. <a href="#">Explore Now</a>";
mysql_close($con)
?>
对于'$ DEITY'的爱,这是2016年**停止使用'mysql_' APIS,并开始使用参数化查询**。 –
阅读CURRENT_TIMESTAMP https://dev.mysql.com/doc/refman/5.5/zh-cn/date-and-time-functions.html#function_current-timestamp - 另外,您还尝试以字符串形式输入。 –
可能重复[MySQL - insert current date/time?](http://stackoverflow.com/questions/19246309/mysql-insert-current-date-time) –