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 Quote Link to comment 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? Quote Link to comment 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 = "you@domain.com"; // 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); ?> Quote Link to comment 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 Quote Link to comment 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 = "you@you.com"; $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); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.