update: add simple db conn
This commit is contained in:
28
serverConnection.php
Normal file
28
serverConnection.php
Normal 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>
|
||||
Reference in New Issue
Block a user