Skip to content

Instantly share code, notes, and snippets.

@LocalCommit
Created April 8, 2015 16:26
Show Gist options
  • Save LocalCommit/716960abdc3993203333 to your computer and use it in GitHub Desktop.
Save LocalCommit/716960abdc3993203333 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)
{
$output = 'Unable to connect to the database server.';
include 'output.html.php';
exit();
}
$output = 'Database connection established.';
include 'output.html.php';
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Script Output</title>
</head>
<body>
<p>
<?php echo $output; ?>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment