<?php
define('DEBUG', TRUE);
class DBException extends Exception {}
$db_host = "localhost:8889";
$db_user = "root";
$db_pass = "root";
$db_name = "php_users";
header('Content-type: text/plain');
try {
if (FALSE === ($conn = mysql_connect($db_host, $db_user, $db_pass))) {
throw new DBException("Could not connect to DB host.");
}
if (FALSE === mysql_select_db($db_name, $conn)) {
throw new DBException("Could not connect to selected DB.");
}
echo "Successfully connected to host and DB!";
} catch (DBException $e) {
echo $e->getMessage() . "\n\n";
if (DEBUG === TRUE) {
echo "MYSQL_ERROR: " . mysql_error() . "\n\n";
print_r($e->getTrace());
}
} catch (Exception $e) {
echo $e->getMessage();
}
?>