update: add simple db conn

This commit is contained in:
Patrick Schulze
2026-05-06 09:03:30 +02:00
parent 7378102b19
commit fa14b89036

28
serverConnection.php Normal file
View File

@@ -0,0 +1,28 @@
<!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>