Skip to content

Instantly share code, notes, and snippets.

@LocalCommit
Last active August 29, 2015 14:19
Show Gist options
  • Save LocalCommit/6de5751d6c24a44a89e1 to your computer and use it in GitHub Desktop.
Save LocalCommit/6de5751d6c24a44a89e1 to your computer and use it in GitHub Desktop.
<?php
try
{
$pdo = new PDO('mysql:host=localhost;dbname=ijdb', 'ijdbuser', 'mypassword');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf8"');
}
catch (PDOException $e)
{
$error = 'Unable to connect to the database server.';
include 'error.html.php';
exit();
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Script Error</title>
</head>
<body>
<p>
<?php echo $error; ?>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment