Re: Error trapping, on scripts that don't exist

From: Date: Wed, 05 Sep 2001 16:14:28 +0000
Subject: Re: Error trapping, on scripts that don't exist
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-66057@lists.php.net to get a copy of this message
This is how it works (in very crude not-even-pseudo code, but I'm sure you'll be able to follow the logic!): BEGIN 1. Browser requests a resource (file) from your web server. 2. Web server checks to see whether requested resource exists. 3. if (!2) web server generates 404 error (page does not exist) & your user is redirected to your custom error screen. Goto END 4. else send requested resource to browser: if it's an HTML file it is sent as-is. Goto END. 5. If it's a php script, send it to the php interpreter to execute. 6. If script is error-free, send result to web server to forward on to browser. Everything AOK. Goto END. 7. Else Error handler does whatever you want it to. In this case, redirect to the same page as in (3) (as well as possibly sending you an email, logging to a file, etc.) END By default step 7 would be printing an error to the browser, which is what I assume you don't want. If someone requests a php file that does not exist, they will get a 404 error since that url does not exist and you won't even get as far running any script at all! "Tim Ward" <tim.ward@stivesdirect.com> wrote in message news:D2AC2CC91E72D511BD5600500416D3C01E6127@hunters-mail.itnetadmin.com... > thanks to Mahmoud for trying to help, but the php error trapping functions > rely on the engine being able to auto-prepend the error trapping script. I > tried a solution like this ... > <?php > if (!file_exists($PATH_TRANSLATED)) > { include("$DOCUMENT_ROOT/error.html"); > exit; > } > ?> > > but it doesn't prepend to scripts that don't exist. I did some diagnostics > (e.g. replacing $PATH_TRANSLATED with a hard coded non-existant file name) > to confirm it was working for files that do exist. > > Any ideas on how to get around this? > > Tim Ward > Senior Systems Engineer > > Please refer to the following disclaimer in respect of this message: > http://www.stivesdirect.com/e-mail-disclaimer.html > > > > -----Original Message----- > > From: Mahmoud Abu-Wardeh [SMTP:mahmoud@infoscience.ltd.uk] > > Sent: 03 September 2001 18:01 > > To: tim.ward@stivesdirect.com > > Subject: Re: Error trapping > > > > Try writing a custom error handler. Chech out > > http://www.zend.com/zend/spotlight/error.php for a good > > article on the > > subject. Pay particular attention to the bit at the end about output > > buffering since I assume that what you would want to do is send a redirect > > header to the browser if the script fails to work. > > > > "Tim Ward" <tim.ward@stivesdirect.com> wrote > > > I've gone an annoying problem. On our site I've trapped "file does not > > > exist" errors at Apache level to send out my own error screen with a > > company > > > logo, link to home page and a mailto link, but this doesn't work for any > > > request for a page that would be parsed by php if it existed. In this > > case > > a > > > valid html page (containing the php error) is returned. The problem > > seems > > to > > > be that as far as Apache is concerned there isn't an error. I haven't > > found > > > anything in php that allows me to trap errors like this. Error reporting > > > levels aren't helpful as I still need the error trapped. > > > > > > I'm sure I'm not the first person who has come across this, and I'm > > hoping > > > someone out there has found a way around it. > > > > > > I'm running PHP 4.0.0, Apache 1.3 on NT (yes I know, but our network > > manager > > > has promised me a linux box) > > > > > > Tim Ward > > > Senior Systems Engineer > > > > > > Please refer to the following disclaimer in respect of this message: > > > http://www.stivesdirect.com/e-mail-disclaimer.html > > > > > > > >

« previous php.general (#66057) next »