From 58b52438a886f0a415a66774e87b5ad7be7f6d07 Mon Sep 17 00:00:00 2001 From: GhadaA98 Date: Sun, 28 May 2023 13:37:02 +0200 Subject: [PATCH] Data base --- connect_db.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/connect_db.php b/connect_db.php index c4480a4..b24967e 100644 --- a/connect_db.php +++ b/connect_db.php @@ -1,15 +1,17 @@ Verbindung nicht hergestellt

"); - }else{ - echo "Verbindung hergestellt!"; - } - - function runSQL($sql){ - global $db_link; - $db_res = mysqli_query($db_link, $sql) or die("SQL_Abfrage: " . $sql . "Fehler: " . mysqli_error($db_link)); - return $db_res; - } + $servername = "141.19.142.11"; + $username = "web_b-3"; + $password = "een7Ao6s"; + $database = "bibliothek_candle"; + + try { + $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password); + $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + echo "Connected successfully"; + } catch(PDOException $e) { + echo "Connection failed: " . $e->getMessage(); + } + + ?> \ No newline at end of file