Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Need help with this code

Featured Replies

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;
}
} 


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 :good:

  • 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 :good:

Im doing great thanks how are u? and nah that still did not work thanks for trying though :)

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.