<?php
echo "Current dir: " . __DIR__ . "<br>";

require_once __DIR__ . '/../config.php';

echo 'DB_HOST='.(defined('DB_HOST')?DB_HOST:'(missing)')."<br>";
echo 'DB_NAME='.(defined('DB_NAME')?DB_NAME:'(missing)')."<br>";
echo 'DB_USER='.(defined('DB_USER')?DB_USER:'(missing)')."<br>";

try {
  $dsn = 'mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4';
  $pdo = new PDO($dsn, DB_USER, DB_PASS, [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
  ]);
  echo 'Connected OK';
} catch (PDOException $e) {
  echo 'ERROR: '.$e->getMessage();
}
