<?php
require_once 'config.php';
$dbs = ['buque_telemetria', 'devmaste_buque_telemetria', 'telemetria'];
echo "<h1>DB Diagnostic</h1>";
foreach ($dbs as $db) {
    echo "<h2>Testing $db...</h2>";
    try {
        $dsn = "mysql:host=localhost;dbname=$db;charset=utf8mb4";
        $p = new PDO($dsn, 'root', '');
        echo "<p style='color:green'>Success!</p>";
        $stmt = $p->query("SHOW COLUMNS FROM mediciones");
        $cols = $stmt->fetchAll(PDO::FETCH_COLUMN);
        echo "<ul><li>" . implode("</li><li>", $cols) . "</li></ul>";
    } catch (Exception $e) {
        echo "<p style='color:red'>Failed: " . $e->getMessage() . "</p>";
    }
}
?>