Created
January 17, 2024 16:04
-
-
Save macloo/af4872230ed37d4e9bc92c46fb962d3d to your computer and use it in GitHub Desktop.
Revisions
-
macloo created this gist
Jan 17, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ <?php // allow error reporting ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); ?> <?php try { // connect to database $conn = mysqli_connect("localhost", "root", "", "myshoutbox"); // check connection if (!$conn) { throw new Exception(); } } catch (Exception $e) { // if connection fails, display error message echo "Error: Unable to connect to database. "; echo " Reason: " . $e->getMessage(); echo ". mysqli_ error number: " . mysqli_connect_errno(); exit; // don't execute any other code on the page } ?>