Basically, I’m working on a spam detection system and I would like to detect if a row was inserted less the x seconds ago. x could be 5 second, so I would want to see if a row was inserted into the table less then 5 seconds ago.
The table name for example purposes could be my_table. This is what I came up with…
$spam_validate = mysql_query("select * FROM my_table WHERE date_time < '3'");
Then I would do….
if (mysql_num_rows($spam_validate)==0) {
//keep going
} else {
echo 'Spam was detected';
}
If any of you could point me into the right direction here, I’m obviously not correct so any help is much appreciated.
You need a timestamp field (can be of type DATETIME) in that table, which you set when you insert the row.
Then you can select against it. This query should work.
Note the DATETIME arithmetic, which is similar to using DATEADD directly.