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 : Example of function to send out email if error occurs
Categories : PHP, Email, Debugging, Errors and Logging Update Picture
JJ Harrison
Date : Sep 30th 2003
Grade : 2 of 5 (graded 5 times)
Viewed : 9102
File : No file for this code example.
Images : No Images for this code example.
Search : More code by JJ Harrison
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php

function reported()
{

$domain = 'mydomain.com';

// ---------------------------------------------------------------

if( isset($_COOKIE['error']) )
{
$_COOKIE['error'] = unserialize( $_COOKIE['error'] );

if( in_array($_SERVER['REQUEST_URI'], $_COOKIE['error']) )
{
return TRUE;
}
}

$_COOKIE['error'][] = $_SERVER['REQUEST_URI'];
$value = serialize( $_COOKIE['error'] );
setcookie( 'error', $value, time() + 24*60*60, '/', './'.$domain, 0 );
unset( $domain, $value );
return FALSE;
}

function error($error='Undefined')

{
if( !reported() )
{
$to = 'someone@example.com';

$subject = "Error type $error has occured on $_SERVER['REQUEST_URI']";

// set the MESSAGE: e-mail
$message = " $error has occured on page:\n"
." http://www.{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}\n"
." Referring Page: ".( isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'Unknown' )." \n"
." Time: ".date('r')."\n"
." From IP: {$_SERVER['REMOTE_ADDR']}\n\n"
."Please Investigate the problem ASAP";

$headers = "From: webserver@{$_SERVER['SERVER_NAME']}\n"
."Reply-To: webserver@{$_SERVER['SERVER_NAME']}\n"
."X-Mailer: PHP/".phpversion();

// send the email
mail( $to, $subject, $message, $headers );
}
}


/*
EXAMPLE for a 404 error page.
error($error='404 Error');
*/
?>



An email validation script that actually checks against the recipient's mail server.
Categories : Email, Complete Programs, PHP, Network, Debugging
Error mailing logging facility
Categories : PHP, Errors and Logging, Email
DB Connection Function with error handling and email failure notices
Categories : PHP, MySQL, Errors and Logging, Databases, Errors and Logging
A Custom Error Handling And Debugging Class
Categories : PHP, PHP Classes, Debugging, Errors and Logging
[PHP5] PHP Debugger and Helper
Categories : PHP, PHP Classes, Errors and Logging, Debugging, XML
Sending email with random details
Categories : PHP, Email, Debugging
The class to check load time of your script VERY usefull for relatively slow applications, but not only..
Categories : PHP, PHP Classes, Debugging
PhpView 0.1 - simple php viewer, using temporary files and frames.
Categories : PHP, PHP Options and Info, Debugging, HTML and PHP
Email a user with out exposing email address
Categories : PHP, Databases, MySQL, Email
Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip
Categories : Email, Network, PHP, PHP Classes
Intelligent 404 Handler
Categories : PHP, Errors and Logging
A web-based php3 IMAP email client supporting address books, attachements (downloading and sending), LDAP searching, and much much more.
Categories : Email, PHP, LDAP
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
email validator check checker email e-mail email address
Categories : PHP, Email, Regexps