Skip to content

Commit

Permalink
style: documentation updated and commented
Browse files Browse the repository at this point in the history
  • Loading branch information
We1337-alpha committed Mar 10, 2024
1 parent 1dde722 commit ba669ca
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Modules/config.php
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
}

0 comments on commit ba669ca

Please sign in to comment.