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!

There are some services to check and email you if your website goes down. A partial list: http://www.webhostingtalk.com/showthread.php?s=&threadid=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.

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?

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! ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.