Home > Archive > PHP Programming > August 2004 > require_once and fatal errors... automatic sleep and try again anyone?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
require_once and fatal errors... automatic sleep and try again anyone?
|
|
| Neil Zanella 2004-08-28, 3:55 am |
| Hello,
I have a PHP page which loads OK 80% of the time. However
the rest of the time I get the following error:
Fatal error: Failed opening required 'DB.php'
This really bugs me, especially since the only reason
this is happeneing seems to be due to server load. I
would like to add code so that instead of displaying
the given error, the PHP code makes the HTTP response
thread simply sleep a little bit (say 4 seconds), and
then retry, and repeat until the file can be opened.
It seems strange to me that server load would prevent
the file from being opened. Anyhow, any ideas on how
I can improve the situation?
Thanks,
Neil
| |
| Von Heler 2004-08-28, 8:55 am |
| On 28 Aug 2004, much to the astonishment of all present at comp.lang.php,
Neil Zanella blurted:
> Hello,
>
> I have a PHP page which loads OK 80% of the time. However
> the rest of the time I get the following error:
>
> Fatal error: Failed opening required 'DB.php'
>
> This really bugs me, especially since the only reason
> this is happeneing seems to be due to server load. I
> would like to add code so that instead of displaying
> the given error, the PHP code makes the HTTP response
> thread simply sleep a little bit (say 4 seconds), and
> then retry, and repeat until the file can be opened.
>
> It seems strange to me that server load would prevent
> the file from being opened. Anyhow, any ideas on how
> I can improve the situation?
>
> Thanks,
>
> Neil
>
Is the domain you are using for this site using a redirect? If so, I have
had a very similar problem which seemed to be solved by using an absolute
URL path to the include (which is ok as long as it is located above root).
| |
| Chung Leong 2004-08-28, 3:56 pm |
| "Neil Zanella" <nzanella@cs.mun.ca> wrote in message
news:b68d2f19.0408272237.620ebe71@posting.google.com...
> Hello,
>
> I have a PHP page which loads OK 80% of the time. However
> the rest of the time I get the following error:
>
> Fatal error: Failed opening required 'DB.php'
>
> This really bugs me, especially since the only reason
> this is happeneing seems to be due to server load. I
> would like to add code so that instead of displaying
> the given error, the PHP code makes the HTTP response
> thread simply sleep a little bit (say 4 seconds), and
> then retry, and repeat until the file can be opened.
Use include_once() instead. That generates a warning instead of a fatal
error when it fails. Suppress the warning with @, then use
get_included_files() to see if the file was included.
> It seems strange to me that server load would prevent
> the file from being opened. Anyhow, any ideas on how
> I can improve the situation?
Don't know. Probably an issue at the OS level.
| |
| Neil Zanella 2004-08-30, 8:56 pm |
| Thanks, your suggestion seems like the best solution to the
problem. Here is the code:
<?php
while (!in_array('DB.php',
array_map('basename', get_included_files()))) {
@include_once('DB.php');
usleep(100000);
}
echo 'finally included!!!';
?>
Regards,
Neil
"Chung Leong" <chernyshevsky@hotmail.com> wrote in message
> Use include_once() instead. That generates a warning
> instead of a fatal error when it fails. Suppress the
> warning with @, then use get_included_files() to see
> if the file was included.
>
>
> Don't know. Probably an issue at the OS level.
|
|
|
|
|