Re: Code Refusing to Die
| From: | rm | Date: | Wed, 18 Jul 2001 20:40:55 +0000 |
| Subject: | Re: Code Refusing to Die | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-58543@lists.php.net to get a copy of this message | ||
$fp is not a valid file handle because the url is
invalid, it can't close a file handle for a file that
wasn't opened because it never existed (invalid url).
You need to fix the logic to allow for the possibility
that a file does not exit and therefore cannot be
closed. Maybe the php function file_exists might be of
some use.
rm
--- Sheridan Saint-Michel <webmaster@foxjet.com>
wrote:
> Okay... I can't figure out why this isn't working...
>
> When I enter in a valid URL this function works
> fine...
>
> The problem is when I enter an invalid url, rather
> than getting my (semi) friendly die error I get
>
> Warning:
>
> fopen("http://www.foxjet.com/html/fjmain.html","r")
> - Unknown error in /home/www/foxjet/admin/mailer.php
> on line 37
>
> Warning: Supplied argument is not a valid
> File-Handle resource in
> /home/www/foxjet/admin/mailer.php on line 38
>
> Warning: Supplied argument is not a valid
> File-Handle resource in
> /home/www/foxjet/admin/mailer.php on line 39
>
>
> Here is my function (With Line numbers added)
>
> 31: Function CreateMessage($url,$boundary)
> 32: {
> 33:
> 34: if (substr($url,0,7) != "http://")
> 35: $url = "http://" . $url;
> 36:
> 37: $fp = fopen($url,"r") or die("Page $url Not
> Found!");
> 38: $buffer = fread($fp, 100000);
> 39: fclose($fp);
>
> /* More Code */
>
> 65: }
>
> Any ideas? Am I overlooking something?
>
> Sheridan Saint-Michel
> Website Administrator
> FoxJet, an ITW Company
> www.foxjet.com
>
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/