Forum Moderators: coopster
function handle_error($err) {
throw new Exception($err);
}
try {
$con = mysql_connect("", "", "") or handle_error("mysql_connect failed! ");
mysql_select_db("") or handle_error("mysql_select_db failed! ");
$sql = "SELECT blah blah blah ...";
$result = mysql_query($sql, $con) or handle_error("mysql_query failed! ");
}
catch(exception $e) {
// Log error in error-log.txt.
trigger_error($e->getMessage() . mysql_error(), E_USER_WARNING);
// Send yourself an email if more than 30 mins (1800 seconds) have passed since previous e-mail.
$last_modified = filemtime('error-log.txt');
$time_elapsed = time() - $last_modified;
if($time_elapsed > 1800) {
error_log($e->getMessage() . "Date: " . date("l jS \of F, Y, h:i:s A") . ". File: " . $_SERVER['REQUEST_URI'], 1, "example@aol.com", "From: example@yahoo.com");
}
}
The two variables ($last_modified and $time_elapsed) are set...
...which would always be just a split second ago
Is it possible to check when I last sent an e-mail?
file_put_contents('last-email-sent.log',time()); $last_sent = (int)file_get_contents('last-email-sent.log');
...and it worked.