Skip to content

Instantly share code, notes, and snippets.

@sebgates
Created September 9, 2017 10:44
Show Gist options
  • Save sebgates/e885ec9bbb93e99540dfe94d1ba33b87 to your computer and use it in GitHub Desktop.
Save sebgates/e885ec9bbb93e99540dfe94d1ba33b87 to your computer and use it in GitHub Desktop.
<?php
$dsn = 'mysql:host=localhost;dbname=MyShop';
$username = 'root';
$password = 'root';
/*
//Option 1 - without using an error page
try {
$db = new PDO($dsn, $username, $password);
} catch (PDOException $e) {
echo $e->getMessage();
exit();
}
*/
/*
//Option 1 - with an error page
try {
$db = new PDO($dsn, $username, $password);
} catch (PDOException $e) {
$error_message = $e->getMessage();
include('database_error.php');
exit();
}
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment