Created
August 4, 2015 10:16
-
-
Save Asselberghs/4897d24a908f7ff2d92d to your computer and use it in GitHub Desktop.
Connecting to a MySQL Database Using PDO.
This file contains 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 | |
$dsn = 'mysql:dbname=Database_Name;host=IP_Address'; | |
$user = 'Username'; | |
$pass = 'Password'; | |
try { | |
$db = new PDO($dsn, $user, $pass); | |
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
} | |
catch(PDOException $e) { | |
die('Could not connect to database:<br />' . $e->getMessage()); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment