Re: Code Refusing to Die

From: Date: Wed, 18 Jul 2001 21:35:45 +0000
Subject: Re: Code Refusing to Die
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58559@lists.php.net to get a copy of this message
I thought about file_exists... but url is by definition a remote file and file_exists does not work on remote files. http://www.php.net/manual/en/function.file-exists.php What I don't understand is why the die statement never executes. If you try to fopen a file that doesn't exist shouldn't fopen return false? Sheridan ----- Original Message ----- From: rm <richand2002@yahoo.com> To: Sheridan Saint-Michel <webmaster@foxjet.com>; php-general <php-general@lists.php.net> Sent: Wednesday, July 18, 2001 3:40 PM Subject: Re: [PHP] Code Refusing to Die > $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/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#58559) next »