<?php
// Database Credentials
define('DB_SERVER', 'localhost');
define('DB_USER', 'wfdhnchq_olatunjikenny694');
define('DB_PASS', 'Mobile@#1234');
define('DB_NAME', 'wfdhnchq_aci_db');

// Set the PHP default timezone
date_default_timezone_set('Africa/Lagos');

// 1. Establish database connection using PDO
try {
    $dbh = new PDO(
        "mysql:host=" . DB_SERVER . ";dbname=" . DB_NAME,
        DB_USER,
        DB_PASS,
        array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'")
    );
    // Set Error Mode to Exception for better debugging
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    // Set MySQL timezone for PDO
    $dbh->exec("SET time_zone = '+01:00'");
} catch (PDOException $e) {
    // In production, you might want to log this instead of exiting
    exit("Database Error (PDO): " . $e->getMessage());
}

// 2. Establish database connection using MySQLi
$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME);

// Check MySQLi connection
if (mysqli_connect_errno()) {
    exit("Failed to connect to MySQL (MySQLi): " . mysqli_connect_error());
} else {
    // Set MySQL timezone for MySQLi
    $con->query("SET time_zone = '+01:00'");
}

/** 
 * IMPORTANT: No closing PHP tag (?>) at the end of this file. 
 * This prevents accidental whitespace from triggering 'Headers already sent' errors.
 */