Help me with my IP bann script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sleepwalker0
Forum Newbie
Posts: 17
Joined: Sun Feb 19, 2006 4:13 pm

Help me with my IP bann script

Post by sleepwalker0 »

I got the structure from the tutorial and heres how my script looks so far

Code: Select all

<?php
$bann = fopen ("C:\www\learning%php\banned.txt", "r"); // this is line 8
$read = fread ($bann, 9000);
fclose($bann)
$badr = explode {$read};                       // this is line 11
if (in_array($REMOTE_ADDR, $badr){ 
echo "Sorry you have been banned";
die; 
}
?>
anyway I get an error on line 8 and 11, cant figure out why.

And I didnt find any info about "$REMOTE_ADDR" but I think its a built in variable for IPs connected to the server right? So yea if you could help me get rid of these errors it would help alot...Thanks.
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Post by LiveFree »

Code: Select all

<?php
$bann = fopen ("C:\www\learning%php\banned.txt", "r"); // this is line 8
$read = fread ($bann, 9000);
fclose($bann);
$badr = explode($read);                       // this is line 11
if (in_array($_SERVER['REMOTE_ADDR'], $badr){ 
echo "Sorry you have been banned";
die; 
}
?>
sleepwalker0
Forum Newbie
Posts: 17
Joined: Sun Feb 19, 2006 4:13 pm

Post by sleepwalker0 »

your version causes error on line 12 ($SERVER[])..

"Parse error: syntax error, unexpected '{' in C:\wamp\www\learning php\ban.php on line 12"
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's missing a second closing paren.
Post Reply