Skip to content

Instantly share code, notes, and snippets.

@rumblestrut
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save rumblestrut/9634425 to your computer and use it in GitHub Desktop.

Select an option

Save rumblestrut/9634425 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Output</title>
</head>
<body>
<?php echo $output; ?>
</body>
</html>
<?php
try
{
$pdo = new PDO('mysql:host=[insert hostname];dbname=[insert database name]', '[insert database user]', '[insert database password]');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf8"');
}
catch (PDOException $e)
{
$output = 'Unable to connect to the database server: ' . $e->getMessage();
include 'output.html.php';
exit();
}
$output = 'Database connection established.';
include 'output.html.php';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment