stig1 Posted July 27, 2009 Share Posted July 27, 2009 I currently use this as my connection function to mysql, however, if the database connection fails there no way of it telling me, instead of using the or die statments i would rather it email me, with the mysql related error no and error msg. Is this possible? class DB_MySQL { var $connection; function DB_MySQL(){ $this->connection = mysql_connect(MYSQL_SERVER, MYSQL_USR, MYSQL_PASS); mysql_select_db(MYSQL_DB, $this->connection); } }; Link to comment https://forums.phpfreaks.com/topic/167688-connection-function/ Share on other sites More sharing options...
ldougherty Posted July 28, 2009 Share Posted July 28, 2009 There is no way in mySQL to be notified via email of any SQL errors. You could however write your own script which checks an error log for any new information after x amount of time via cron and emails you the results if found. Link to comment https://forums.phpfreaks.com/topic/167688-connection-function/#findComment-884426 Share on other sites More sharing options...
.josh Posted July 28, 2009 Share Posted July 28, 2009 function email_db_error() { $to = "[email protected]"; $subject = "db error"; $content = "The following error occured on: " . date("Y.m.d H:i:s") . "\n\n"; $content.= mysql_error(); mail($to,$subject,$content); } // example $conn = mysql_query('blah') or trigger_error(email_db_error()); Link to comment https://forums.phpfreaks.com/topic/167688-connection-function/#findComment-884430 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.