Hi I have a simple database connection test php file (index.php) that is supposed to call another page (output.html.php) with the include statement but it does not seem to work. Please help. Below is the code for both files. Thank you.
index.php
:
<?php
try
{
$pdo = new PDO('mysql:host=localhost;dbname=ijdb', 'ijdbuser', 'mypassword');
$pdo->setAttribute(PDO::ALTER_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';
?>
output.html.php
:
<!DOCTYPE html>
<html lang="en-us">
<meta charset="UTF-8" >
<title>DB Example</title>
<head>
</head>
<body>
<p>
<?php echo $output; ?>
</p>
</body
</html>
I just get blank page.