PHP error help

software development


Hi, I have a small piece of php code to add to my existing php file.

It give an error and I have brought it back to 1 line:

the error show:

Warning: include(ip_files/.php) [function.include]: failed to open stream: No such file or directory in …

Which suggests to me that the php code “.$numbers[0].” does not works to view the different 259 files in that folder (ip_files). I tested it by doing include(“ip_files/10.php”); and the error was gone.

Any replacement code for that, since the script is from 2009?

This is also regarding thread , but this question should be here.


What it suggests is the value of $numbers[0] is empty or not defined.

Having said that, where is the $numbers array values set?


Even your question goes above my knowledge, sorry.

This is the complete code I added to the existing php:



function iptocountry($ip)
$numbers = preg_split( “/./”, $ip);

$code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);

foreach($ranges as $key => $value)

if ($country=="")

return $country;

if (!isset($_SESSION[‘FirstVisit’]))
if ($two_letter_country_code==“US”)
$_SESSION[‘FirstVisit’] = 1;

Of course I could always do:
all the way up to 259, but that seems not the right way.


Either you are not running the script in a web server environment, PHP is not able to access the web server variables, the value the web server/PHP is passing for the IP address is not what is expected, or the function preg_split() is not being called correctly. It could also be a flaw in the code that determines which variable to get the IP address from; most of the time isset() is called to determine if a variable has a value.


Thanks for your help, even if I don’t understand any of it.

Anyway I found a replacement code

foreach (glob(“ip_files/*.php”) as $filename)
include $filename;

which gets rid of the error, but after several tests, the website just does not get blocked for me.

I also tried a straight forward .htaccess block (my IP) and that did not block the website for me.

So I am tempted to give up on the whole blocking idea.