Testdatei 1
Claude 3.5 generated
This commit is contained in:
commit
68ba1de058
1 changed files with 45 additions and 0 deletions
45
test-php.php
Normal file
45
test-php.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
echo "<h1>MySQL Connection Test</h1>";
|
||||
|
||||
// Connection details from docker-compose.yml
|
||||
$host = 'db'; // This should be the service name from docker-compose
|
||||
$user = 'root';
|
||||
$password = 'rootpassword';
|
||||
$database = 'database';
|
||||
|
||||
// Try MySQLi connection
|
||||
echo "<h2>Testing MySQLi Connection:</h2>";
|
||||
try {
|
||||
$mysqli = new mysqli($host, $user, $password, $database);
|
||||
if ($mysqli->connect_error) {
|
||||
throw new Exception($mysqli->connect_error);
|
||||
}
|
||||
echo "MySQLi Connection successful!<br>";
|
||||
echo "Server info: " . $mysqli->server_info . "<br>";
|
||||
$mysqli->close();
|
||||
} catch (Exception $e) {
|
||||
echo "MySQLi Connection failed: " . $e->getMessage() . "<br>";
|
||||
}
|
||||
|
||||
// Try PDO connection
|
||||
echo "<h2>Testing PDO Connection:</h2>";
|
||||
try {
|
||||
$dsn = "mysql:host=$host;dbname=$database";
|
||||
$pdo = new PDO($dsn, $user, $password);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
echo "PDO Connection successful!<br>";
|
||||
echo "Server info: " . $pdo->getAttribute(PDO::ATTR_SERVER_VERSION) . "<br>";
|
||||
} catch (PDOException $e) {
|
||||
echo "PDO Connection failed: " . $e->getMessage() . "<br>";
|
||||
}
|
||||
|
||||
// Additional system information
|
||||
echo "<h2>System Information:</h2>";
|
||||
echo "PHP Version: " . phpversion() . "<br>";
|
||||
echo "Loaded PHP Extensions:<br><pre>";
|
||||
print_r(get_loaded_extensions());
|
||||
echo "</pre>";
|
||||
?>
|
Loading…
Add table
Reference in a new issue