Re: NEWBIE.. Major problems with fopen() ??
| From: | Matthias Redl | Date: | Wed, 07 May 2003 15:39:01 +0000 |
| Subject: | Re: NEWBIE.. Major problems with fopen() ?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146692@lists.php.net to get a copy of this message | ||
Hi Christian,
I'm not sure if fopen() supports HTTP1.1 which is necessary to open files
from another virtual server. If fopen() only supports HTTP1.0 (which I
believe), then PHP will first resolve the host to the IP Address
62.61.159.110. Since the file is not availabe at
http://62.61.159.110/test.txt it will not be able to
open it.
If that's the case you will have to use a 3rd party class that supports
HTTP1.1. A class that is capable of that is called
"class.HttpConnection.inc" is available at
http://phpclasses.mkdata.net/browse.html/package/172.html
Matthias
"Cdn" <news@cdn.dk> schrieb im Newsbeitrag
news:20030428084131.56361.qmail@pb1.pair.com...
> Hi
>
> I am trying to start up a PHP site and i need som information from a *.txt
> file from another site but when i use "fopen" I get :
>
> "Warning: fopen(http://www.cdn.dk/test.txt, "r") - No such file or
directory
> in /customers/roskilderoklub.dk/roskilderoklub.dk/httpd.www/php/test1.php
on
> line 7"
> My code looks like this :
>
> <?php
> $WindStr = '';
> $DirStr = '';
>
> ini_set("allow_url_fopen", "On");
>
> $handle=fopen("http://www.cdn.dk/test.txt",
> "r");
> @$WindStr = fread($handle, 93);
> @$WindStr = fread($handle, 5);
> @$DirStr = fread($handle, 5);
> @$DirStr = fread($handle, 5);
>
> @fclose($handle);
>
> echo "<p><font face='Verdana' size='1'
> color='#007F7F'><br><br><b>Wind
Speed
> ".$WindStr." m/s Dir
> ".$DirStr."</b></font></p>";
>
> ?>
>
> The server is running PHP 4.2.2 could that be the problem ?
> Can the provider disable fopen(url) funktion ?
> I have tryed alot but with out luck.
> How do you get this PHP working ?.
>
> Christian...
>
>