From aa0209afeff188a6574173bb3be70057402d9c74 Mon Sep 17 00:00:00 2001 From: Felix Eckhofer Date: Sun, 24 Apr 2016 16:07:55 +0200 Subject: [PATCH] Fix error 500 on database connect error If `$connection===false` it obviously has no properties. --- php/Modules/Database.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/php/Modules/Database.php b/php/Modules/Database.php index 2df65dc..d194cdc 100755 --- a/php/Modules/Database.php +++ b/php/Modules/Database.php @@ -56,7 +56,7 @@ final class Database { $connection = self::connect($host, $user, $password); // Check if the connection was successful - if ($connection===false) Response::error($connection->connect_error); + if ($connection===false) Response::error(self::connect_error()); if (self::setCharset($connection)===false) Response::error('Could not set database charset!'); @@ -90,6 +90,13 @@ final class Database { } + /** + * @return string Returns the string description of the last connect error + */ + public static function connect_error() { + return mysqli_connect_error(); + } + /** * @return boolean Returns true when successful. */