-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-db.php
More file actions
34 lines (29 loc) · 954 Bytes
/
test-db.php
File metadata and controls
34 lines (29 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
// Test database connection
$servername = "localhost";
$username = "root";
$password = "";
try {
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "<h1>Database Connection Test</h1>";
echo "<p style='color: green;'>✓ Successfully connected to MariaDB!</p>";
echo "<p>Server version: " . $conn->server_info . "</p>";
// Show databases
$result = $conn->query("SHOW DATABASES");
echo "<h2>Available Databases:</h2>";
echo "<ul>";
while($row = $result->fetch_assoc()) {
echo "<li>" . $row["Database"] . "</li>";
}
echo "</ul>";
$conn->close();
} catch (Exception $e) {
echo "<h1>Database Connection Test</h1>";
echo "<p style='color: red;'>✗ Connection failed: " . $e->getMessage() . "</p>";
}
?>
<hr>
<p><a href="welcome.html">← Back to Welcome</a></p>