Results 1 to 12 of 12

Thread: Costum Errors

  1. #1

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Costum Errors

    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
    If there is only one perfect person in the universe, does that make them imperfect?

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Costum Errors

    Would you care to elaborate?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Re: Costum Errors

    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/
    If there is only one perfect person in the universe, does that make them imperfect?

  4. #4
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Re: Costum Errors

    Then the link your using is wrong perhaps? :s
    Don't Rate my posts.

  5. #5

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Re: Costum Errors

    ok? i am using this code as my error handler:
    PHP Code:
    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?
    If there is only one perfect person in the universe, does that make them imperfect?

  6. #6
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Re: Costum Errors

    ?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. :\
    Don't Rate my posts.

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Costum Errors

    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:
    $code = substr($_GET['err'], 0, strpos($_GET['err'], '?'));
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Costum Errors

    Quote Originally Posted by dandono
    ok? i am using this code as my error handler:
    PHP Code:
    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
    Code:
    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.

  9. #9
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Costum Errors

    This is IIS though, it addsthe info automagically. - so don't put anything in yourself, just the name of the error document.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Costum Errors

    Oh IIS. Missed that

  11. #11

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Re: Costum Errors

    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?
    If there is only one perfect person in the universe, does that make them imperfect?

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Costum Errors

    Apparently IIS automatically appends ?<code>;<document> to whatever error document you set. Therefore you can do this:
    Code:
    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.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width