Weird problem using fopen()

I'm having some strange problems using fopen() to fetch website
content.

It seems I can't open URL shorter then certain lenght.

I can open this:
http://groups.google.co.uk/groups/dir?lnk=od&h=en&sel=&x=sss ssxsssq

But if I delete a character from the end, fopen() failes after 20 sec
and returns strange error:
....failed to open stream: HTTP request failed! \xf4\xff$ in...
....failed to open stream: HTTP request failed! \x94\x93\xeb in...
....failed to open stream: HTTP request failed! \xa0\x82\xfa\xb7 [at] \x18%
in...

I mean, what is up with that? Any ideas?

Thanks!!

Server is running Apache 2.0.59, PHP 5.1.6 on CentOS 4.4. The same
thing happened when box was running Fedora Core 5.

This is the code I'm testing with:

<?php
$url = "http://groups.google.co.uk/groups/dir?
lnk=od&h=en&sel=&x=sssssxsssq";
echo strlen($url);
if ($fp = fopen($url,"r"))
{
while (!feof($fp))
{
$buffer = fgets($fp, 4096);
echo $buffer;
}
}
else
{
echo "ERR";
}
?>
milan.topalov [ Mi, 21 März 2007 10:47 ] [ ID #1664363 ]

Re: Weird problem using fopen()

I'm a PHP newbie, but I'm having similar results. Mine doesn't appear
to have to do with the length - both of your urls work for me - but
some work and others don't.

I can open:
http://www.thinkgeek.com/thinkgeek.rss

but not:
http://digg.com/rss/containertechnology.xml

I get the same "failed to open stream: HTTP request failed!" warning.

Here's my stripped-down code:

$fp = fopen($url, "r");
if($fp !== false)
{
$out = file_get_contents($url);
fclose($fp);
}
else
{
$out = "Not opened";
}
echo $out;


I'm all ears!
Andy
wizard04b [ Fr, 23 März 2007 20:46 ] [ ID #1666789 ]
PHP » alt.php » Weird problem using fopen()

Vorheriges Thema: avast checks PHP files?
Nächstes Thema: PHP __FILE__ directive is not functioning correctly?