PDA

View Full Version : Test if connected to MySQL


SusanH
05-15-2007, 04:02 PM
I've used this little script a few times to test if I am able to connect to my MySQL database with my web host. Maybe someone can find it of use and/or share other ways you test your MySQL connections.

testconnect.php
<?php
$link = mysql_connect('localhost', 'your_username', 'your_db_passwd');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

Have fun ;)