WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Error mailing logging facility
Categories : PHP, Errors and Logging, Email Click here to Update Your Picture
Ioannis Cherouvim
Date : Dec 03rd 2005
Grade : 4 of 5 (graded 1 times)
Viewed : 2948
File : 4262.php
Images : No Images for this code example.
Search : More code by Ioannis Cherouvim
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php
//***************************************************************
//** title  : Error mailing logging facility
//**
//** file   : error.php
//**
//** story  : When your site is live you never want people to see
//**          php errors no matter what. Sometimes this is possible
//**          though because your host might upgrade PHP or MySQL
//**          or something else can go bad. The usual advice given
//**          is to have error_reporting(0) on the live sites. But
//**          then you will never get to know that an error is there.
//**         
//**          I use a different approach here. I set error reporting
//**          to E_ALL (that is report all errors) but I have
//**          over-ridden the error handler to construct a nice
//**          error report and mail it to me. The application
//**          continues, and if the error was not major, the user
//**          will never get to notice anything. You on the other
//**          side though will know that something has gone wrong
//**          and you'll run to fix it.
//**
//**          Customize the $to and $from variables, include this
//**          file and enjoy.
//**         
//**          You are going to get something like this:
//**         
//**          Date    : December 3, 2005, 3:55:12 am
//**          Server  : example.com
//**          Error No: 8
//**          On file : /home/example/public_html/temp/error.php
//**          On line : 35
//**          Error   : Use of undefined constant bar - assumed 'bar'
//**          IP      : 87.203.242.37
//**          Host    : athedsl-12355.otenet.gr
//**          Method  : GET
//**          Vars    :
//**                    name => test
//**                    age = 55
//**
//**
//** author : Ioannis Cherouvim
//** web    : http://cherouvim.com
//** date   : 2005-12-03
//***************************************************************
 
 
 
error_reporting(E_ALL);
 
  function
errorHandler($errno, $errstr, $errfile, $errline, $errcontext) {
   
$ret[] = "Date    : " . date("F j, Y, g:i:s a");
   
$ret[] = "Server  : " . $errcontext['_SERVER']['SERVER_NAME'];
   
$ret[] = "Error No: $errno";
   
$ret[] = "On file : $errfile";
   
$ret[] = "On line : $errline";
   
$ret[] = "Error   : $errstr";
   
$ret[] = "IP      : " . $errcontext['_SERVER']['REMOTE_ADDR'];
   
$ret[] = "Host    : " . gethostbyaddr($errcontext['_SERVER']['REMOTE_ADDR']);
   
$ret[] = "Method  : " . $errcontext['_SERVER']['REQUEST_METHOD'];
   
$ret[] = "Vars    :";
    foreach(
$errcontext['_REQUEST'] as $key=>$value)
     
$ret[] = "          $key => $value";
   
$error = "";
    foreach(
$ret as $line)
     
$error .= "$line\n";
   
   
$to = "example@yahoo.com";
   
$from = "Error Catcher <errors@example.com>";
   
$headers = "To: $to\r\n";
   
$headers .= "From: $from\r\n";
   
mail($to, "Error on " . $errcontext['_SERVER']['SERVER_NAME'], $error, $headers);
  }
 
 
$old_error_handler = set_error_handler("errorHandler");
 
 
 
//do something stupid to produce an error.
  //it's for testing purposes, please remove
 
$foo = $bar;
?>



DB Connection Function with error handling and email failure notices
Categories : PHP, MySQL, Errors and Logging, Databases, Errors and Logging
Example of function to send out email if error occurs
Categories : PHP, Email, Debugging, Errors and Logging
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
A simple function to prevent undefined $_POST/$_GET/$_SESSION variable errors
Categories : PHP, Variables, Errors and Logging
Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip
Categories : Email, Network, PHP, PHP Classes
A web-based php3 IMAP email client supporting address books, attachements (downloading and sending), LDAP searching, and much much more.
Categories : Email, PHP, LDAP
Encoding data using PGP via PHP's proc_* functions
Categories : Cryptography, Security, Email, PHP, PGP
email validator check checker email e-mail email address
Categories : PHP, Email, Regexps
Mail-lib provides a simple interface to the sendmail program. Note: you must actually have sendmail on your machine (sorry windows NT users).
Categories : Algorithms, Email, PHP
PHPRecommend v1.0 - "Recommend this page to a friend" script written in PHP. Easy to install
Categories : PHP, URLs, Complete Programs, Email, Site Planning
PHP based Contact email form with multiple recipients, text file based, supports departments.
Categories : PHP, Email, Beginner Guides, Filesystem
validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email addresses via SMTP and regex.
Categories : Email, Regexps, PHP
Logging 404 errors in your custom statistics using Apache and a PHP script.
Categories : Apache, Web Servers, PHP, Errors and Logging
making links from text
Categories : PHP, Regexps, Email
HTTP Basic Authentication via POP3.
Categories : Authentication, HTTP, Email, PHP