Skip to content

Instantly share code, notes, and snippets.

@bcalloway
Created August 4, 2010 18:47
Show Gist options
  • Save bcalloway/508598 to your computer and use it in GitHub Desktop.
Save bcalloway/508598 to your computer and use it in GitHub Desktop.
Basic test for db connection
<?php
//test database connection
// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
// Attempt to connect to MySQL
if ($dbc = mysql_connect ($host, $user, $pass)) {
print '<p>Successfully connected to MySQL.</p>';
mysql_close(); // Close the connection.
} else {
die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment