This is a discussion on help within the PHP Language forums, part of the PHP Programming Forums category; <?php $ip = $_SERVER['REMOTE_ADDR']; $bestand = "ipblock.txt"; $iparray = file("ipblock.txt"); $ans = array_search($ip, $iparray); ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
<?php
$ip = $_SERVER['REMOTE_ADDR']; $bestand = "ipblock.txt"; $iparray = file("ipblock.txt"); $ans = array_search($ip, $iparray); if ($ans == $ip) { print(" "); print("<div align='center'><font face='Geneva, Arial, Helvetica, sans-serif'><strong>Your ip [$ip] has been suspended as a result of your actions on this website</strong></font></div>"); print ("<div align='center'><font face='Geneva, Arial, Helvetica, sans-serif'><strong>-------------------------------------------------------- -</strong></font></div>"); } else { $db = mysql_connect("localhost","user","password"); ....etc Why does this not work?? And in which format must i add ip adresses into the file?? FiremanSAM |
|
|||
|
FiremanSAM wrote:
[...] > $ans = array_search($ip, $iparray); > > if ($ans == $ip) { [...] >Why does this not work?? And in which format must i add ip adresses into the >file?? After reading http://www.php.net/array_search the first reason that comes to mind is that you're comparing the array index ($ans) to the array value ($ip). Check that you compare "comparable" things! I think the file should have something like 10.11.12.13 10.43.76.109 Happy Coding :-) -- I have a spam filter working. To mail me include "urkxvq" (with or without the quotes) in the subject line, or your mail will be ruthlessly discarded. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|