:: Your Computer Technical Resource Headquarters! :: Your Computer Technical Resource Headquarters!
Computer Support Forums arrow Software Support arrow Database Problems arrow Topic: Error handling
June 14, 2021, 10:15:41 PM

Home Forum Rules Help Search Mobile Version Login Register

Welcome, Guest. Please login or register.
Did you miss your activation email?
June 14, 2021, 10:15:41 PM

Login with username, password and session length
 Featured Sites:
New  Got pics of your modded PC or want to show off your cool desktop, visit our new Show & Tell forum!
  0 Members and 1 Guest are viewing this topic.
Pages: [1] Go Down Print
Author Topic: Error handling  (Read 3450 times)

Karma: +0/-0
Offline Offline

Posts: 3

Bookmark and Share

View Profile
« on: December 06, 2007, 07:54:47 AM »

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:
/*-- start output buffering--*/
/*-- live site --*/
/*-- 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";
/*-- error message for live site should not give any detail about problem, just an apology --*/
$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 --*/
} else {
/*-- if site is in testing print the acual error messages --*/
echo '<div class="error">'.$message.'</div><br/>';
/*-- as everything is defined now, set the error handler, so it's ready to be used --*/

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.

Pages: [1] Go Up Print 
Jump to:  

Powered by MySQL Powered by PHP

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS!

This site is NOT responsible for any damage that the information on this site may cause to your system. Everything you try, whether inspired by the response given from this site or not, is entirely at your own risk. All product names and company names used herein are for identification purpose only and may be trademarks or registered trademarks of their respective owners. We are in no way affiliated or representing any of the companies on this site unless specified.
Back to Top
Stop Spam Harvesters, Join Project Honey Pot Fight Back Against Spammers! Get Firefox! Get Thunderbird! View Sylvain Amyots profile on LinkedIn
Back to Top
Google visited last this page December 30, 2019, 12:20:33 AM