[英]Error #1064 in mySQL Query
I get the following error in the query below: 我在下面的查询中收到以下错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near ')))' at line 1
INSERT INTO test_bans( ip, Expiration )
VALUES (
"0.0.0.0", DateAdd(
"d", 1, Date( )
)
)
CREATE TABLE test_bans (
ID smallint(6) NOT NULL AUTO_INCREMENT,
IP text NOT NULL,
Expiration DATETIME NOT NULL,
PRIMARY KEY (ID)
) TYPE=MyISAM;
What am I missing? 我错过了什么?
Edit, after running this query I got this error. 编辑,运行此查询后,我收到此错误。 I guess my ew question is how do I add a day to my current timestamp? 我想我的问题是如何在当前的时间戳中添加一天?
#1305 - FUNCTION optimuscprime.DateAdd does not exist
Query: 查询:
INSERT INTO test_bans( ip, Expiration )
VALUES (
"0.0.0.0", DateAdd(
"d", 1,
CURRENT_TIMESTAMP
)
)
Try to use simple SQL, not the MySQL-dialect: 尝试使用简单的SQL,而不是MySQL方言:
INSERT INTO test_bans( ip, Expiration )
VALUES (
'0.0.0.0', (NOW() + INTERVAL 1 DAY)
);
DATE() takes arguments, you should use NOW() to use the current date/time or other date functions. DATE()接受参数,你应该使用NOW()来使用当前的日期/时间或其他日期函数。
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
As for the day +1.. in PHP I would do something like: 至于PHP中的+1 ..我会做类似的事情:
strtotime('+1 day', time());
You could also use INTERVAL with MySQL with the link provided. 你也可以使用带有MySQL的INTERVAL和提供的链接。
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add
DATE()
should have an argument. DATE()
应该有一个参数。 You may want to use NOW()
instead. 您可能希望使用NOW()
代替。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.