diff --git a/required.php b/required.php index b81e8b8..ad6b0df 100644 --- a/required.php +++ b/required.php @@ -106,7 +106,10 @@ try { 'server' => $SETTINGS['database']['server'], 'username' => $SETTINGS['database']['user'], 'password' => $SETTINGS['database']['password'], - 'charset' => $SETTINGS['database']['charset'] + 'charset' => $SETTINGS['database']['charset'], + 'option' => [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION + ] ]); } catch (Exception $ex) { //header('HTTP/1.1 500 Internal Server Error'); @@ -145,23 +148,6 @@ function dieifnotloggedin() { } } -/** - * Check if the previous database action had a problem. - * @param array $specials int=>string array with special response messages for SQL errors - */ -function checkDBError($specials = []) { - global $database; - $errors = $database->error(); - if (!is_null($errors[1])) { - foreach ($specials as $code => $text) { - if ($errors[1] == $code) { - sendError($text); - } - } - sendError("A database error occurred:
" . $errors[2] . ""); - } -} - function redirectIfNotLoggedIn() { global $SETTINGS; if ($_SESSION['loggedin'] !== TRUE) {