PDA

Click to See Complete Forum and Search --> : Costum Errors


dandono
Dec 16th, 2005, 06:55 AM
hi, i am making an error handler using IIS 6 and PHP (obviously). when i triger an error iis is ment to return /errors/error.php?404 but it does not and returns /errors/error.php?404?404;http://domain:80/rnddir/
how can i get it to not send that extra data?
thanks, dandono

visualAd
Dec 20th, 2005, 11:11 AM
Would you care to elaborate?

dandono
Dec 20th, 2005, 12:23 PM
ok. i have made an error handler for my website running iis. how it works it that iis goes to the same page on every error like for http 404 it would give the user /errors/error.php?404 but insted of doing that it gives the user /errors/error.php?404?404;http://path.com/pathwotiswrong/

Pc_Madness
Dec 20th, 2005, 05:03 PM
Then the link your using is wrong perhaps? :s

dandono
Dec 20th, 2005, 05:21 PM
ok? i am using this code as my error handler:
if ($err == "404")
{
$h1 = 'Header/Title';
$body = 'Body Line one. Describes the Error encountered.
<br>Body Line two. Tells the user what they can do.';
}
what it is ment to send for that to work is ?err=404 but insted it is getting ?err=404?404;blah.thing
how can i get it to not either send the ?404;blah.thing or get my code to be able to read that. can any one help?

Pc_Madness
Dec 20th, 2005, 05:42 PM
?err=404?404;blah.thing

Would indicate that thers an error in your code. Check whichever file it is that sends you to the page ?err=404. Sounds like your missing a "

I think. :\

visualAd
Dec 21st, 2005, 04:59 AM
The variable $_GET['err'] will contain "404?404;blah.thing" so all you need to do is extract the protion of the stirng which contains the error code, anything before the ?:

$code = substr($_GET['err'], 0, strpos($_GET['err'], '?'));

penagate
Dec 21st, 2005, 06:21 AM
ok? i am using this code as my error handler:
if ($err == "404")
{
$h1 = 'Header/Title';
$body = 'Body Line one. Describes the Error encountered.
<br>Body Line two. Tells the user what they can do.';
}
what it is ment to send for that to work is ?err=404 but insted it is getting ?err=404?404;blah.thing
how can i get it to not either send the ?404;blah.thing or get my code to be able to read that. can any one help?

In that case you are sending it wrongly, what are you using to direct to the error page?

I use the .htaccess page to set my error URL, as follows
ErrorDocument 404 http://mydomain.com/error.php?id=404

Then in error.php just check the value of $_GET['id']. If you it that way nothing extra should get sent.

visualAd
Dec 21st, 2005, 07:09 AM
This is IIS though, it addsthe info automagically. :) - so don't put anything in yourself, just the name of the error document.

penagate
Dec 21st, 2005, 07:11 AM
Oh IIS. Missed that :)

dandono
Dec 21st, 2005, 08:59 AM
thanks for the replys and thanks visualad. if i changed iis so insted of the error doc being /errors/error.php?err=404 to /errors/error.php and insted of using $code = substr($_GET['err'], 0, strpos($_GET['err'], '?')); i used $code = substr($_GET['err'], 0, strpos($_GET['err'], ';')); would that work?

CornedBee
Dec 21st, 2005, 10:20 AM
Apparently IIS automatically appends ?<code>;<document> to whatever error document you set. Therefore you can do this:
list($code, $url) = explode(';', $_SERVER['argv'][1]);
It might be [0], I'm not sure.

You need to change your IIS config so that it only points to /errors/error.php, though, not /errors/error.php?err=404.