Go Back   Webmaster Forums UK SEO SEM Webmaster Community Forum - UKWW > Web Design and Website Development > Programming > PHP Forum
Register FAQ Members List Downloads Calendar Today's Posts Webmaster Resources Webmaster Blogs
 
 

PHP Forum PHP related discussion, help, tips and tutorials.

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-24-2007, 09:20 PM
Senior Member
 
Join Date: Feb 2007
Posts: 148
Default Error handling

We struggle to come up with a decent error handling function. I thought that I use a global variable $live to easily make a switch from testing to live. I will keep the function in an include file.
I kind of got there to print a "user-friendly" message when the site is live, but it messes up the whole page layout. Don't how to print the error message in the content area. How would I adjust my error handler and what would I add to "<?php require_once $content; ?>"?

My error handler:
<?php
/*-- start output buffering--*/
ob_start();
/*-- live site --*/
$live=TRUE;
/*-- error handling function giving back error number, the actual message, the error file, the error line and the variables (what are variable in this context?) --*/
function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars) {
/*-- make $live global --*/
global $live;
/*-- set error message for testing together --*/
$message="Error in file '$e_file' on line $e_line: $e_message\n";
$message.=print_r($e_vars,1);
/*-- error message for live site should not give any detail about problem, just an apology --*/
if($live){
$user="We apologise for the problems on this page...";
/*-- if there are error messages print the standard user message --*/
if ($message==0){echo $user;}else{
/*-- otherwise say 'hi there' --*/
echo ('');}
/*-- do it only once as user should not see the apology more than once --*/
exit();
} else {
/*-- if site is in testing print the acual error messages --*/
echo '<div class="error">'.$message.'</div><br/>';
}
}
ob_end_flush();
/*-- as everything is defined now, set the error handler, so it's ready to be used --*/
set_error_handler('my_error_handler');
?>

Also, in the bit "if ($message==0)" I would have thought that comparing $message to 1 would have printed the user-friendly error message (as I thought 1 means that there is one or more error message).


Any help appreciated.

Lala
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Closed Thread

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Webmaster Resources
 
The Forum Rules
Forum Rules - MUST READ
 
Site Of the Month
BizzFace
Nominate site of the month
 
Tag Cloud
armani t-shirt background check belts cheap itunes code claim coogi t-shirt cool courses css cv writing dior shoes dodjit dumps dumpsquestions dynamic portal engine earn from sms ecommerce developer ecommerce solution fashion g-star jeans google gucci html to joomla images increase traffic internet marketing introduction it edu itunes gift certificate jeans joomla kayu latest dumps matrimoanil matrimonial script medical transcription money mt jobs news non oversold online website builder part time earning people check personal prada shoes psd to joomla puma purses records check road selling online seo seo and traffic seo tips shoes sms earning sport shoes stock tableless pixel ticketing uk usa hosting versace t-shirt wallets web design website traffic increased wikigalore wood textures work from home writing services xhtml

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error Bagi Zoltán PHP Forum 3 11-25-2007 04:30 PM
Error gone? temi General Webmaster Talk 3 09-26-2007 12:15 PM
Installation - SQL error northernwc Boss Cart Installation Help 12 09-19-2006 10:43 AM
661 error jacky820 iG Shop 3 12-17-2004 01:52 AM
Fatal error pteixeira iG Shop 1 04-10-2004 01:36 AM


All times are GMT. The time now is 01:25 PM.

UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons.
Subscribe to our feeds   Subscribe to our feeds

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0