Skip to content

Commit

Permalink
FIX: Added error handling for MySQL Connection
Browse files Browse the repository at this point in the history
  • Loading branch information
hippo23 committed Jul 21, 2022
1 parent 93dea77 commit 151ed89
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Binary file added .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions src/act3.php → src/act4.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php session_start(); ?>
<?php include './database.php'; ?>

<!DOCTYPE HTML>
<html class='h-auto w-full bg-black'>
<html class='h-auto w-full bg-white'>

<head>
<meta charset="UTF-8">
Expand All @@ -16,6 +15,7 @@
</head>

<body class='w-full h-auto m-0 p-0 text-base border-none'>
<?php include './database.php'; ?>
<div class='w-full h-screen h-screen flex lg:flex-row flex-col items-center justify-around bg-white'>
<?php include './masthead.php'; ?>
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', '');
define('DB_NAME', 'pokemon');
define('DB_NAME', 'poemon');

$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

if ($conn->connect_error) {
die('Connection failed' . $conn->connect_error);
try {
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
} catch (Exception $e) {
echo '<script>alert("Warning: The site was unable to connect to the local database. Functions will not work.")</script>';
}

0 comments on commit 151ed89

Please sign in to comment.