<?php
// DB connection
$host = 'localhost';
$user = 'adamspri_admin';
$pass = 'adamspri@2025';
$db   = 'adamspri_school';

$conn = new mysqli($host, $user, $pass, $db);

// Force utf8mb4 for full Unicode support
$conn->set_charset("utf8mb4");

// Create a test table
$conn->query("CREATE TABLE IF NOT EXISTS unicode_test (
    id INT AUTO_INCREMENT PRIMARY KEY,
    content TEXT
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");

// Insert test string
$test_string = "Test chemical formula: H₂CO₄, SO₄²⁻, Na⁺, ∆E = q + w";

$stmt = $conn->prepare("INSERT INTO unicode_test (content) VALUES (?)");
$stmt->bind_param("s", $test_string);
$stmt->execute();

// Retrieve and display
$result = $conn->query("SELECT * FROM unicode_test ORDER BY id DESC LIMIT 1");
$row = $result->fetch_assoc();

echo "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Unicode Test</title></head><body>";
echo "<h3>Stored & Retrieved Content:</h3>";
echo "<p>" . htmlspecialchars($row['content'], ENT_QUOTES, 'UTF-8') . "</p>";
echo "</body></html>";

$conn->close();
?>
