mysql error in query for timestamp interval
Posted
by
nik parsa
on Stack Overflow
See other posts from Stack Overflow
or by nik parsa
Published on 2012-10-13T15:29:23Z
Indexed on
2012/10/13
15:37 UTC
Read the original article
Hit count: 359
I have voting_IP table as follow:
+-----------+-------------+------+-----+---------+----------------+
| 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 | |
+-----------+-------------+------+-----+---------+----------------+
I want to run this query which has errors and I don't know how to correct it?
$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);)");
I also tried this one:
$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);))");
© Stack Overflow or respective owner