May 2, 201016 yr This is a basic flood control function i made for my custom blog but its not working can u point out where im going wrong thanks in advance function fcontrol($field,$delay){ $u_ip = $_SERVER['REMOTE_ADDR']; $c_time = time(); $s = "SELECT {$field}_time AS time FROM fcontrol WHERE ip = '".$u_ip."'"; $r2 = mysql_query($s) or die ("Cant"); if(mysql_num_rows($r2) == 0){ mysql_query("INSERT INTO fcontrol (`ip`,{$field}_time) VALUES ('$u_ip',$c_time)"); return true; }else{ $time = mysql_fetch_assoc($r2); $time = $time['time']; if($c_time - $time > $delay){ mysql_query("UPDATE fcontrol SET {$field}_time = $c_time WHERE ip = '".$ip."' "); return true; }else{ return false; } }
May 2, 201016 yr Hey mate, how you doing? To potentially solve your problem, change the following lines: mysql_query("INSERT INTO fcontrol (`ip`,{$field}_time) VALUES ('$u_ip',$c_time)"); and mysql_query("UPDATE fcontrol SET {$field}_time = $c_time WHERE ip = '".$ip."' "); To: mysql_query("INSERT INTO fcontrol (ip,{$field}_time) VALUES ('$u_ip','$c_time')"); and mysql_query("UPDATE fcontrol SET {$field}_time = '$c_time' WHERE ip = '$ip' "); Not entirely sure this will fix your problems, but your queries caused SQL errors for me
May 2, 201016 yr Author Hey mate, how you doing? To potentially solve your problem, change the following lines: mysql_query("INSERT INTO fcontrol (`ip`,{$field}_time) VALUES ('$u_ip',$c_time)"); and mysql_query("UPDATE fcontrol SET {$field}_time = $c_time WHERE ip = '".$ip."' "); To: mysql_query("INSERT INTO fcontrol (ip,{$field}_time) VALUES ('$u_ip','$c_time')"); and mysql_query("UPDATE fcontrol SET {$field}_time = '$c_time' WHERE ip = '$ip' "); Not entirely sure this will fix your problems, but your queries caused SQL errors for me Im doing great thanks how are u? and nah that still did not work thanks for trying though
May 3, 201016 yr Im doing great thanks how are u? and nah that still did not work thanks for trying though I'm well thanks Have you tried setting die("So far so good..."); breakpoints in the code to see where the function gets to at present?
Create an account or sign in to comment