<?php
// config.php – put this in your backend root and include with require_once()

// 1) Suppress on-screen errors, log them instead
ini_set('display_errors', 1);
ini_set('log_errors',     1);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_WARNING);

// 2) Define your DB constants if they’re not already set
if (! defined('DB_NAME'    )) define('DB_NAME',     'pickum');
if (! defined('DB_USER'    )) define('DB_USER',     'root');
if (! defined('DB_PASSWORD')) define('DB_PASSWORD', 'Jysa6$djhN93*d333461');
if (! defined('DB_HOST'    )) define('DB_HOST',     'localhost');
if (! defined('DB_PORT'    )) define('DB_PORT',     '3306');

// 3) Connect to MySQL (host, user, pass, db, port)
$mysqli = new mysqli(
    DB_HOST,
    DB_USER,
    DB_PASSWORD,
    DB_NAME,
    (int) DB_PORT
);
$mysqli->query("SET time_zone = '+03:00'");

// If connection fails, immediately return JSON and stop
if ($mysqli->connect_error) {
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode([
        'success' => false,
        'error'   => 'Database connection failed'
    ]);
    exit;
}

// 4) Always use UTF-8 for your queries & JSON
$mysqli->set_charset('utf8');
header('Content-Type: application/json; charset=utf-8');

// (No closing PHP tag — prevents accidental trailing whitespace)
