simple mysql health check page

Simple? Yes. Useful? Yes.

Although the below is very simple it can be a very useful and effective way to regularly check apache functionality and its ability to communicate with mysql.

<title>Test mysql communications</title>
$dbhost = 'localhost:3306';
$dbuser = 'trunty';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn)
die('Could not connect: ' . mysql_error());
echo 'Connected successfully';

A URL that this can be seen in action is http://dev.linuxismybff.com/test/mysql/mysqltestconnect.php

No comments:

Post a Comment