Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.