tags:

views:

74

answers:

3

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

Code Snippet:

INSERT INTO test_bans( ip, Expiration )
    VALUES (
    "0.0.0.0", DateAdd(
    "d", 1, Date( )
    )

) 

Table creation query

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
)
) 
+3  A: 

DATE() takes arguments, you should use NOW() to use the current date/time or other date functions.

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:

strtotime('+1 day', time());

You could also use INTERVAL with MySQL with the link provided.

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add

Kevin
They look balanced to me in that sample, if placed oddly (the lone paren at the end of the code is suspicious).
Donal Fellows
Yup, they're all there.
William
+3  A: 

DATE() should have an argument. You may want to use NOW() instead.

Donal Fellows
please look at the edit.
William
+2  A: 

Try to use simple SQL, not the MySQL-dialect:

INSERT INTO test_bans( ip, Expiration )
    VALUES (
    '0.0.0.0', (NOW() + INTERVAL 1 DAY)
);
Frank Heikens
That worked, thank you very much. ^_^
William