Browse Source

Merge pull request #530 from tribut/connect-error

Fix error 500 on database connect error
Tobias Reich 8 years ago
parent
commit
3bf4790487
1 changed files with 8 additions and 1 deletions
  1. 8 1
      php/Modules/Database.php

+ 8 - 1
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.
 	 */