diff --git a/resources/classes/database.php b/resources/classes/database.php index 1ab0f06acc..8ef7853c32 100644 --- a/resources/classes/database.php +++ b/resources/classes/database.php @@ -1227,7 +1227,15 @@ include "root.php"; if ($prep_statement) { //get the data try { - $prep_statement->execute(); + $res_exec = $prep_statement->execute(); + if ($res_exec === false) { + $errInfo = $prep_statement->errorInfo(); + if (isset($errInfo[2])) { + throw new RuntimeException($errInfo[2]); + } else { + throw new RuntimeException("Error executing SQL statement"); + } + } $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); } catch(PDOException $e) { @@ -1235,6 +1243,11 @@ include "root.php"; echo $sql; exit; } + catch(RuntimeException $e) { + echo 'Caught exception: ', $e->getMessage(), "

\n"; + echo $sql; + exit; + } //set the action if (count($result) > 0) {