Skip to content

Instantly share code, notes, and snippets.

@YupItsZac
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YupItsZac/a05a82f0748499f6c03d to your computer and use it in GitHub Desktop.
Save YupItsZac/a05a82f0748499f6c03d to your computer and use it in GitHub Desktop.
Connect to MySQL with PDO
try {
$conn = new PDO('mysql:host=localhost;dbname=myDatabase', $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment