diff --git a/setup.php b/setup.php
index 1627be8f..c486c8e1 100644
--- a/setup.php
+++ b/setup.php
@@ -785,10 +785,10 @@ if (isset($_POST['add_database'])) {
$installation_id = randomString(32);
// Test database connection before writing it to config.php
- try {
- mysqli_connect($host, $username, $password, $database);
- } catch (Exception $e) {
- exit("Database connection failed - please check and try again
$e");
+
+ $conn = mysqli_connect($host, $username, $password, $database);
+ if (!$conn) {
+ exit("Database connection failed - please check and try again
" . mysqli_connect_error());
}
$new_config = "Company Details