WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 : 6525
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  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
Protect your email links from being spidered by spam email robots!
Categories : PHP, Security, Mail, Email
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
cPanel Email Accounts Creator
Categories : PHP, PHP Classes, Email, Form Processing, Web Services
send_mail function to defeat Header Injection Hacking/Spamming
Categories : PHP, Email, Form Processing, Security
Customer feedback or simple emailer - A PHP script that enables your visitors to send you emails.
Categories : PHP, Email, Form Processing
Encoding data using PGP via PHP's proc_* functions
Categories : Cryptography, Security, Email, PHP, PGP
A class for sending email; it has support for To:, Cc:, Bcc: and Reply-To: headers. It requires that you have sendmail installed.
Categories : Email, PHP Classes, PHP
Protect your mailto: email addresses from bots
Categories : PHP, Email, Java Script
A web-based php3 IMAP email client supporting address books, attachements (downloading and sending), LDAP searching, and much much more.
Categories : Email, PHP, LDAP
PHP MIME Decoder. This class decodes Mime Encoded email message. Attachments are stored in a director. Works with Multipart/alternative, multipart/mixed etc. see http://p3mail.com for example.
Categories : PHP, PHP Classes, Email
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
An email validation script that actually checks against the recipient's mail server.
Categories : Email, Complete Programs, PHP, Network, Debugging
Three Cool Classes and One Trick
Categories : PHP, PHP Classes, Graphics, Email