Created
June 22, 2012 12:34
-
-
Save Riaan-ZA/2972509 to your computer and use it in GitHub Desktop.
PHP: PDO - Database Connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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