<?php
// Database connection for MySQL (PDO)
$host = 'localhost';
$db = 'zfhfpsz1_muanjai';
$user = 'zfhfpsz1_muanjai';
$pass = 'JoeyAnou9160';
$charset = 'utf8mb4';
$collation = 'utf8mb4_unicode_ci';

// PDO Connection
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$options = [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES => false,
];
try {
    $pdo = new PDO($dsn, $user, $pass, $options);
    // ตั้ง collation
    $pdo->exec("SET NAMES '$charset' COLLATE '$collation'");
} catch (PDOException $e) {
    die('Connection failed: ' . $e->getMessage());
}

// MySQLi Connection (for admin pages)
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
    die('MySQLi Connection failed: ' . $conn->connect_error);
}
$conn->set_charset($charset);

?>