Verbindung zur Datenbank wieder hergestellt

master
GhadaA98 2023-05-28 16:13:02 +02:00
parent 58b52438a8
commit 914cc5ebe7
1 changed files with 12 additions and 14 deletions

View File

@ -1,17 +1,15 @@
<?php
$db_link = mysqli_connect('localhost', 'web_b-3', 'een7Ao6s', 'bibliothek_candle', '3306');
$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();
}
if(!$db_link){
die("<p>Verbindung nicht hergestellt</p>");
}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;
}
?>