gfmitchell Posted November 23, 2007 Share Posted November 23, 2007 Hi can anyone help me as I'm new to php. When connection to the database fails I would like to include an email link in the response message, but I need help with how it can be done. Below is my code and I want the error message text to include a Report This email html link. <?php //connect to MySQL $host = "localhost"; $user = "username"; $pass = "password"; $error = "There is a problem with connection to the server please Report This (email link here)"; $connect = mysql_connect($host,$user,$pass) or die ($error); ?> Thanks for the help Link to comment https://forums.phpfreaks.com/topic/78569-solved-connection-to-database-or-die-message/ Share on other sites More sharing options...
adam291086 Posted November 23, 2007 Share Posted November 23, 2007 Are you wanting the user to fill out some text boxes and then send an email to you, letting you know they had an error while visting your site? Link to comment https://forums.phpfreaks.com/topic/78569-solved-connection-to-database-or-die-message/#findComment-397561 Share on other sites More sharing options...
~n[EO]n~ Posted November 23, 2007 Share Posted November 23, 2007 You can try like this, $email variable holds your email id <?php //connect to MySQL $email = "[email protected]"; // change your email here $host = "localhost"; $user = "username"; $pass = "password"; $error = "There is a problem with connection to the server please Report This (<a href=\"mailto:$email\"'>Click here to mail<a>)"; $connect = mysql_connect($host,$user,$pass) or die ($error); ?> Link to comment https://forums.phpfreaks.com/topic/78569-solved-connection-to-database-or-die-message/#findComment-397564 Share on other sites More sharing options...
gfmitchell Posted November 23, 2007 Author Share Posted November 23, 2007 Thats exactly what I want many thanks Link to comment https://forums.phpfreaks.com/topic/78569-solved-connection-to-database-or-die-message/#findComment-397568 Share on other sites More sharing options...
gfmitchell Posted November 23, 2007 Author Share Posted November 23, 2007 just to add a bit more here is the full code to add a subject and body to the email. <?php //connect to MySQL $host = "localhost"; $user = "username"; $pass = "password"; $email = "[email protected]"; $subject = "connection.php"; $body = "There is a problem with the connection to the database, please investigate"; $error = "There is a problem with connection to the server please (<a href=\"mailto:$email?subject=$subject&body=$body\"'>Report This<a>)"; $connect = mysql_connect($host,$user,$pass) or die ($error); ?> Link to comment https://forums.phpfreaks.com/topic/78569-solved-connection-to-database-or-die-message/#findComment-397579 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.