diff --git a/init.php b/init.php index 7e18a92..dcabee3 100644 --- a/init.php +++ b/init.php @@ -1,6 +1,6 @@ PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - PDO::ATTR_EMULATE_PREPARES => false - ]; - - $dsn = "pgsql:host=$host;dbname=$db;port=$port"; - $pdo = new PDO($dsn, $user, $pass, $opt); +// Initializes Database Connection +try { + $opt = [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::ATTR_EMULATE_PREPARES => false + ]; + $dsn = "pgsql:host=$host;dbname=$db;port=$port"; + $pdo = new PDO($dsn, $user, $pass, $opt); - // Error-Message - } catch(PDOException $e) { - echo "Error: ".$e->getMessage(); - } +// Creates Error Message +} catch(PDOException $e) { + echo "Error: ".$e->getMessage(); +} + ?> \ No newline at end of file