0

我有以下voting_IP 表:

+-----------+-------------+------+-----+---------+----------------+
| Field     | Type        | Null | Key | Default | Extra          |
+-----------+-------------+------+-----+---------+----------------+
| ip_id     | int(11)     | NO   | PRI | NULL    | auto_increment |
| mes_id_fk | int(11)     | YES  | MUL | NULL    |                |
| ip_add    | varchar(40) | YES  |     | NULL    |                |
| timestamp | datetime    | YES  |     | NULL    |                |
+-----------+-------------+------+-----+---------+----------------+

我想运行这个有错误但不知道如何纠正的查询?

$ip_sql=mysql_query("select ip_add from Voting_IP where mes_id_fk='$id' and ip_add='$ip' and timestamp > (DATE_ADD(now(), INTERVAL -1 HOUR);)");

我也试过这个:

$ip_sql=mysql_query("select ip_add from Voting_IP where (mes_id_fk='$id' and ip_add='$ip' and timestamp > (DATE_ADD(now(), INTERVAL -1 HOUR);))");
4

1 回答 1

2
INTERVAL -1 HOUR);))");
                 ^-----here is the error extra semicolon 

你可以看到错误mysql_query("your query ") or die(mysql_error())

替换为:

INTERVAL -1 HOUR))");
于 2012-10-13T15:32:50.810 回答