Send mail on MYSQL connection failure

Reply

Join Date: Jul 2005
Posts: 2
Reputation: Koldar is an unknown quantity at this point 
Solved Threads: 0
Koldar Koldar is offline Offline
Newbie Poster

Send mail on MYSQL connection failure

 
0
  #1
Jul 1st, 2005
Hi there,
I was trying to get a script working that will fire me an email when my database cannot be connected to. This is what I have and I'm wondering if it looks right to you php experts.

$conn = mysql_connect ($server,$user,$pass) or die(mail("$SendToEmail", "$yoursubject", $emailtext . mysql_error(), "From: $email"));


Also, does anyone know how to have an email sent when the appache services stop running (i.e. website unavailable). I'm trying to track how many times my isp's services fail. I plan on setting up a cronjob that will run the above line every 5 minutes along with one that checks to see if my site is still accessible.

Thank you for your time and brain power!
Last edited by happygeek; May 14th, 2007 at 7:55 am. Reason: Real name removed from post as requested
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 360
Reputation: Gary King will become famous soon enough Gary King will become famous soon enough 
Solved Threads: 5
Team Colleague
Gary King's Avatar
Gary King Gary King is offline Offline
PHP/vBulletin Guru

Re: Send mail on MYSQL connection failure

 
0
  #2
Jul 1st, 2005
There are some services to check and email you if your website goes down. A partial list: http://www.webhostingtalk.com/showth...hreadid=400382

Also, your PHP code looks right. Have you tried testing it? You can test it by changing your MySQL database info, for instance, so that it cannot connect.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 54
Reputation: senexom is an unknown quantity at this point 
Solved Threads: 0
senexom's Avatar
senexom senexom is offline Offline
Junior Poster in Training

Re: Send mail on MYSQL connection failure

 
0
  #3
Jul 3rd, 2005
Also read about PHP's error handling abilities...

http://aspn.activestate.com/ASPN/doc...-handling.html
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 2
Reputation: Koldar is an unknown quantity at this point 
Solved Threads: 0
Koldar Koldar is offline Offline
Newbie Poster

Re: Send mail on MYSQL connection failure

 
0
  #4
Jul 7th, 2005
Thank you for the resources. I've checked out the site monitoring services and signed up for a couple of them already. Are any of you familiar with CPanel? I guess that my ultimate goal is to create a script similar to the site monitor that is bundled with CPanel. I'm just not familiar enough with PHP and Apache to know where all of the services and variables are located to tell me when, for example, mail is down or apache itself has stopped running. Are there any other places you might be able to send me to help out with finding a way to monitor those services as well?
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 360
Reputation: Gary King will become famous soon enough Gary King will become famous soon enough 
Solved Threads: 5
Team Colleague
Gary King's Avatar
Gary King Gary King is offline Offline
PHP/vBulletin Guru

Re: Send mail on MYSQL connection failure

 
0
  #5
Jul 8th, 2005
Originally Posted by Koldar
Thank you for the resources. I've checked out the site monitoring services and signed up for a couple of them already. Are any of you familiar with CPanel? I guess that my ultimate goal is to create a script similar to the site monitor that is bundled with CPanel. I'm just not familiar enough with PHP and Apache to know where all of the services and variables are located to tell me when, for example, mail is down or apache itself has stopped running. Are there any other places you might be able to send me to help out with finding a way to monitor those services as well?
If you run a site monitor script on your website to monitor the website, then when the website is down, you won't know, and neither will the script - since the script goes down when the website does!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 3504 | Replies: 4
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC