Jump to content

ip ban


chriscloyd

Recommended Posts

heres my php script for checking for bans

[code]<?php
//checkbans
include("db.php");
$ip = $_SERVER['REMOTE_ADDR'];
$cip = mysql_query("SELECT * FROM bans WHERE ip = $ip");
if ($cip) {
$reason = $checkip['reason'];
header("Location : banned.php?reason=".$reason."");
}
?>[/code]

and i have this running off my localhost so i put ip 127.0.0.1 in the database but it wont send me to the banned.php page
Link to comment
https://forums.phpfreaks.com/topic/27908-ip-ban/
Share on other sites

i changed my code to
[CODE]
<?php
//checkbans
include("db.php");
$ip = $_SERVER['REMOTE_ADDR'];
$cip = mysql_query("SELECT * FROM bans WHERE ip = $ip") or die(mysql_error());
if ($cip) {
$reason = $checkip['reason'];
header("Location: banned.php?reason=".$reason."");
}
?>
[/CODE]

and now i get the error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.0.1' at line 1
Link to comment
https://forums.phpfreaks.com/topic/27908-ip-ban/#findComment-127624
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.