Skip to content

Instantly share code, notes, and snippets.

@gaker
Created December 12, 2012 21:00
Show Gist options
  • Save gaker/4271587 to your computer and use it in GitHub Desktop.
Save gaker/4271587 to your computer and use it in GitHub Desktop.
quick and dirty MySQL connection test script for someone.
<?php
$dbname = '';
$hostname = '';
$user = '';
$pass = '';
try {
$dbh = new PDO('mysql:host='.$hostname.';dbname='.$dbname, $user, $pass);
$dbh->exec("SET CHARACTER SET utf8");
$dbh = null;
echo "it worked!\n";
} catch (PDOException $e) {
echo "Error!: " . $e->getMessage() . "<br/>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment