Files
php-project/serverConnection.php
2026-05-06 09:03:30 +02:00

29 lines
709 B
PHP

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>Mein erste PHP website</h1>
<h3>
<?php
$serverName = "localhost";
$userName = "root";
$password = "1234";
$dbName = "AG";
try {
$conn = new PDO("mysql:host=$serverName;dbname=$dbName", $userName, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Conncted successfully";
$conn = null;
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
?>
</h3>
</body>
</html>