Results 1 to 2 of 2

Thread: Catching Errors -[RESOLVED]-

  1. #1

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Resolved Catching Errors -[RESOLVED]-

    While the code is running say something like a database error ocours. I'm handling these using the @ before the functiosn then checking if the result is false. But if it is false then I want to scrap all the output so far and send a new page. Do I have to use a buffer or can I get away doing it without? Thanx.
    Last edited by Electroman; Nov 13th, 2004 at 10:37 PM.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Yes - you'll need to turn on output buffering. In my applications I usually create a function similar to die() which clears all output buffers and then outputs the error:

    Something like this:
    PHP Code:
    <?php
        
    function error ($msg)
        {
            
    $level ob_get_level();

            while (
    $level 0) {
                
    ob_end_clean();
                --
    $level;
            }
    ?>
        <html>
        <head>
            <title>Photo Albums - Error</title>
        </head>
        <body>
            <span class="error"><?php echo($msg?></span>
        </body>
    <?php
            
    exit;
        }
    ?>
    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.

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