runnerjp Posted March 30, 2010 Share Posted March 30, 2010 The data below does not stop flooding if post is within the last 2min... as you can see i have all error reporters in place... the query works fine... Numbers of rows returned are 1... but no error message ??? //stop flooding $query = "SELECT max(unix_timestamp(`time`)) as t FROM messages WHERE reciever='$un' AND sender='$username'"; $res = mysql_query($query); if (!$res) { $errmsg = mysql_errno() . ' ' . mysql_error(); echo "<br/>QUERY FAIL: "; echo "<br/>$sql <br/>"; die($errmsg); } $num = mysql_num_rows($res); if (!$num) { echo "<br/>QUERY FOUND NO DATA: "; echo "<br/>$sql <br/>"; } if(!$res) die("Query: $query\nError: ".mysql_error()); $lastMessageTime = mysql_num_rows($res) == 1 ? array_shift(mysql_fetch_array($res)) : 0; if ($lastMessageTime > 0 && $lastMessageTime < strtotime('+2 Minutes', $timestamp)) { $errors[] = 'Please wait 2 minutes between each message'; } Link to comment https://forums.phpfreaks.com/topic/196985-php-message-flooding-not-showing-error/ Share on other sites More sharing options...
premiso Posted March 30, 2010 Share Posted March 30, 2010 Why not do the time check inside the sql? $query = "SELECT sender FROM messages WHERE `time` < DATE_ADD(`time`, INTERVAL 2 MINUTE) AND (reciever='$un' AND sender='$username') ORDER BY `time` DESC LIMIT 1"; Then if a row is returned by the query, they are considered flooding. This is untested. For more information on DATE_ADD see the MySQL Reference Manual. Link to comment https://forums.phpfreaks.com/topic/196985-php-message-flooding-not-showing-error/#findComment-1034153 Share on other sites More sharing options...
runnerjp Posted March 30, 2010 Author Share Posted March 30, 2010 i gave it ago and no rows get displayed sadly...time is a timestamp tho! Link to comment https://forums.phpfreaks.com/topic/196985-php-message-flooding-not-showing-error/#findComment-1034160 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.