Verbindung zur Datenbank wieder hergestellt
parent
58b52438a8
commit
914cc5ebe7
|
@ -1,17 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
$db_link = mysqli_connect('localhost', 'web_b-3', 'een7Ao6s', 'bibliothek_candle', '3306');
|
||||||
|
|
||||||
$servername = "141.19.142.11";
|
if(!$db_link){
|
||||||
$username = "web_b-3";
|
die("<p>Verbindung nicht hergestellt</p>");
|
||||||
$password = "een7Ao6s";
|
}else{
|
||||||
$database = "bibliothek_candle";
|
echo "Verbindung hergestellt!";
|
||||||
|
}
|
||||||
try {
|
|
||||||
$conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
|
function runSQL($sql){
|
||||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
global $db_link;
|
||||||
echo "Connected successfully";
|
$db_res = mysqli_query($db_link, $sql) or die("SQL_Abfrage: " . $sql . "Fehler: " . mysqli_error($db_link));
|
||||||
} catch(PDOException $e) {
|
return $db_res;
|
||||||
echo "Connection failed: " . $e->getMessage();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue