In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
says...
> I think I'm pretty close to getting this right (maybe!), I've been reading
> through the manual, but can't seem to work it out. I keep getting this
> error:
>
> [Mon Jul 22 19:03:24 2002] [error] PHP Warning: Supplied argument is not a
> valid File-Handle resource in index.php on line 66
>
> I'm trying to open a URL, read the contents, then pull out specific info
> found between specific HTML tags. This is what I have so far:
>
> 63| <?php
> 64| $filename =
> fopen("http://www.kinyradio.com/juneaunews/latest_juneau_news.html", "r");
> 65| $contents = fread($filename, 1000000);
> 66| while($headlines = fscanf($filename, "<p style=\"padding-left:
> 45\"><font face=\"Verdana\" size=\"3\"><b>%[a-zA-Z0-9,. ]</b></font>",
> $headline)) {
> 67| extract($headlines);
> 68| print "<a
> href=\"http://www.kinyradio.com/juneaunews/latest_juneau_news.html\">$headli
> ne</a><br>";
> 69| }
> 70| fclose($filename);
> 71| ?>
>
> Any ideas? Any other functions I could try instead of fscanf()?
That error indicates that fopen failed to open the requested file. Given
that the URL works fine in a browser, is it possible that your php is not
configured to do remote fopen? Check the setting of allow_url_fopen in
phpinfo()
It is a good idea to test the result of such calls before trying to use
the result:
fopen('Whatever') or exit('Couldn't get it, Boss!');
or
if(fopen('whatever') {
do good things;
}else{
bleat vigorously;
}
Cheers
--
David Robley
Temporary Kiwi!
Quod subigo farinam
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php