Re: [PHP] Code Refusing to Die

2001-07-18 Thread rm

try using fsockopen from the php network functions
works better than fopen...we use it to run wget on one
of our machines...fopen is supposed to report
false on failure, however, we don't use it for
connections outside our file system and even then we
always use file_exists before using fopen on the local
machine...it should report false.

> 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?
> 


__
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Code Refusing to Die

2001-07-18 Thread Sheridan Saint-Michel

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 <[EMAIL PROTECTED]>
To: Sheridan Saint-Michel <[EMAIL PROTECTED]>; php-general
<[EMAIL PROTECTED]>
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 <[EMAIL PROTECTED]>
> 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, 10);
> > 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Code Refusing to Die

2001-07-18 Thread rm

$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 <[EMAIL PROTECTED]>
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, 10);
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]