Skip to content

Instantly share code, notes, and snippets.

@Riaan-ZA
Created June 22, 2012 12:34
Show Gist options
  • Save Riaan-ZA/2972509 to your computer and use it in GitHub Desktop.
Save Riaan-ZA/2972509 to your computer and use it in GitHub Desktop.
PHP: PDO - Database Connection
<?php
$db_name = "sport24";
$db_user = "root";
$db_pass = "";
$db_host = "localhost";
try {
$db = new PDO("mysql:host=".$db_host.";dbname=".$db_name."", $db_user, $db_pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e) {
echo $e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment