-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: documentation updated and commented
- Loading branch information
1 parent
1dde722
commit ba669ca
Showing
1 changed file
with
7 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
<?php | ||
|
||
// Include the database configuration file | ||
require_once("db_config.php"); | ||
|
||
try { | ||
$conn = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET, DB_USER, DB_PASSWORD); | ||
// Create a new PDO connection using the provided database credentials | ||
$conn = new PDO("mysql:host=" . DB_HOST . ";port=" . DB_PORT . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET, DB_USER, DB_PASSWORD); | ||
|
||
// Set PDO attributes to enable error handling | ||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
} catch (PDOException $e) { | ||
// Handle any exceptions that might occur during the connection setup | ||
// Print an alert message with the error details if the connection fails | ||
echo "<div class='alert alert-info' role='alert'>Connection failed: " . $e->getMessage() . "</div>"; | ||
} | ||
// $conn = null; connection closed | ||
} |