
Originally Posted by
wonshikee
You should be using a single wrapper function to do the initial logging. What happens within this function could be broken down depending on what and why the logger was called and how complex it is.
Okay, some follow-up questions/concerns...
1.) If I am in "Script A", and I include "Script B", then is it correct that all variables in "Script A" can be seen in "Script B", and that all variables in "Script B" can be seen in "Script A"?
2.) My "results.php" script is 2,141 lines long... Most of that is code like this...
PHP Code:
// Message Sent.
case 'REPLY_MESSAGE_SENT_2193':
echo '<h1>Message Sent</h1>';
echo '<p>Congratulations!</p>';
echo '<p>Your Response has been sent. (2193)</p>';
echo '<a class="button" href="' . BASE_URL . '/account/messages/incoming">Return to Messages</a>';
break;
It seems like that is quite a bit to put into a Function nested in my "utilities/function.php" script...
3.) As I randomly scan through my various Errors, I notice that often I am passing a different set of values to my "results.php" script.
A "standard" call to "results.php" would look like this...
PHP Code:
}else{
// Section Not found in URL.
$_SESSION['resultsCode'] = 'ARTICLE_INDEX_NO_QUERY_STRING_2422';
// Set Error Source.
$_SESSION['errorPage'] = $_SERVER['SCRIPT_NAME'];
// Redirect to Display Outcome.
header("Location: " . BASE_URL . "/account/results.php");
// End script.
exit();
}//End of ATTEMPT TO RETRIEVE ARTICLES
However, I am often passing *other* values to customize my Error Messages like this...
PHP Code:
// Verify Insert.
if (mysqli_stmt_affected_rows($stmt3)==1){
// Insert Succeeded.
$_SESSION['resultsCode'] = 'COMMENT_MEMBER_COMMENT_ADDED_2052';
// LOOK HERE ===>
// Set values for Success Message.
$_SESSION['firstName'] = $firstName;
$_SESSION['heading'] = $heading;
// Notify Other Subscribed Members
notifySubscribersOfNewComment($dbc, $articleID, $commentID, $sessMemberID);
}else{
// Insert Failed.
$_SESSION['resultsCode'] = 'COMMENT_MEMBER_COMMENT_FAILED_2053';
}// End of VERIFY INSERT.
// Set Error Source.
$_SESSION['errorPage'] = $_SERVER['SCRIPT_NAME'];
// Redirect to Display Outcome.
header("Location: " . BASE_URL . "/account/results.php");
// End script.
exit();
So my question here is, "How could I write a Function that would adjust to handle a varying number of arguments?"
4.) I *always* want to log messages in my database, whether they are "Error Messages" or "Success Messages".
HOWEVER, at this time, I only want to e-mail the Administrator if there is an "Error Message".
So, do I need another argument/parameter that tells my "results.php" script - or maybe a new Function - whether or not it should also e-mail the Admin?
Maybe something like this...
PHP Code:
log_error($errorCode, $scriptName, $emailAdmin=FALSE){
}
Sorry for all of the questions, but I'm really not sure how to create a more sophisticated Error-Handler?!
Thanks,
Debbie
Bookmarks