chriscloyd Posted November 20, 2006 Share Posted November 20, 2006 heres my php script for checking for bans[code]<?php//checkbansinclude("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 More sharing options...
fert Posted November 20, 2006 Share Posted November 20, 2006 is't because your viewing it in a web browser and when you do that it send your IP address and not 127.0.0.1 Link to comment https://forums.phpfreaks.com/topic/27908-ip-ban/#findComment-127617 Share on other sites More sharing options...
Psycho Posted November 20, 2006 Share Posted November 20, 2006 echo $ip to the page and add that ip to the database. Link to comment https://forums.phpfreaks.com/topic/27908-ip-ban/#findComment-127621 Share on other sites More sharing options...
chriscloyd Posted November 20, 2006 Author Share Posted November 20, 2006 i have done both ip addess my 68.104.210.230 and that oneand when i did echo $ip it shows 127.0.0.1 Link to comment https://forums.phpfreaks.com/topic/27908-ip-ban/#findComment-127622 Share on other sites More sharing options...
chriscloyd Posted November 20, 2006 Author Share Posted November 20, 2006 i changed my code to [CODE]<?php//checkbansinclude("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 More sharing options...
chriscloyd Posted November 20, 2006 Author Share Posted November 20, 2006 i got it to worki just didnt do '$ip' on the mysql_query Link to comment https://forums.phpfreaks.com/topic/27908-ip-ban/#findComment-127626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.