Good error flagging | PHP

Posted by Wayne on Stack Overflow See other posts from Stack Overflow or by Wayne
Published on 2010-04-16T23:23:00Z Indexed on 2010/04/16 23:33 UTC
Read the original article Hit count: 253

Filed under:
|
|

For everyone that was thinking of the error_reporting() function, then it isn't, what I need is whenever a MySQL query has been done, and the statement has like

if($result)
{
    echo "Yes, it was fine... bla bla";
}
else
{
    echo "Obviously, the echo'ing will show in a white page with the text ONLY...";
}

Whenever statements have been true or false, I want the error to be appeared when redirected with the header() function and echo the error reporting in a div somewhere on the page.

Basically something like this:

$error = '';

This part appears inside the div tags

<div><?php echo $error; ?></div>

So the error part will be echoed when redirected with the header()

if($result)
{
    $error = "Yes, it was fine... bla bla";
    header("Location: url");
}
else
{
    $error = "Something wrong happened...";
    header("Location: url");
}   

But that just doesn't work :(

© Stack Overflow or respective owner

Related posts about php

Related posts about error-message