<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once 'config.php';

$socket = '/opt/lampp/var/mysql/mysql.sock';
echo "Attempting to connect to " . DB_HOST . " as " . DB_USER . " via socket $socket...\n";

$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME, 3306, $socket);

if ($conn->connect_error) {
    echo "Connection failed: " . $conn->connect_error . "\n";
    echo "Error number: " . $conn->connect_errno . "\n";
} else {
    echo "Successfully connected to database: " . DB_NAME . "\n";

    // Check categories
    $result = $conn->query("SELECT id, name FROM service_categories");
    if ($result) {
        echo "Categories found:\n";
        while ($row = $result->fetch_assoc()) {
            echo "- [" . $row['id'] . "] " . $row['name'] . "\n";
        }
    } else {
        echo "Error fetching categories: " . $conn->error . "\n";
    }
    $conn->close();
}
?>