alert('Failure to connect');";
$error = 'Unable to connect to pubs database server.';
include 'error.html.php';
}
// else select database, although it isn't necessary given
// the approach used to connect.
else if (!mysqli_select_db($connection, $database))
{
$error = 'Unable to locate the pubs database.';
include 'error.html.php';
}
// else issue sql query
else
{
$sqlString = "select title from titles;";
try
{
foreach ($connection->query($sqlString) as $row)
{
echo $row['title'] . '
';
}
}
catch (mysqli_sql_exception $e)
{
$error = 'Error fetching query results: ' . mysqli_error($connection);
include 'error.html.php';
}
}
?>