Troubeshoots error displaying

main
Yasen Pramatarov 2024-11-08 12:38:19 +02:00
parent c245bbb3be
commit 686d2c1153
3 changed files with 31 additions and 12 deletions

View File

@ -13,10 +13,9 @@ function connectDB($config, $database = '', $dbFile = '', $platformId = '') {
'type' => 'sqlite',
'dbFile' => $dbFile,
]);
return ['db' => $db, 'error' => null];
} catch (Exception $e) {
$error = getError('Error connecting to DB.', $e->getMessage());
include '../app/templates/block-message.php';
exit();
return ['db' => null, 'error' => getError('Error connecting to DB.', $e->getMessage())];
}
// connecting to a jilo-web database of the web app
@ -30,10 +29,12 @@ function connectDB($config, $database = '', $dbFile = '', $platformId = '') {
'dbFile' => $config['db']['sqlite_file'],
]);
$pdo = $db->getConnection();
return $db;
} catch (Exception $e) {
$error = getError('Error connecting to DB.', $e->getMessage());
include '../app/templates/block-message.php';
exit();
return $error;
// include '../app/templates/block-message.php';
// exit();
}
// mysql/mariadb database
} elseif ($config['db']['db_type'] === 'mysql' || $config['db']['db_type'] === 'mariadb') {
@ -47,10 +48,12 @@ function connectDB($config, $database = '', $dbFile = '', $platformId = '') {
'password' => $config['db']['sql_password'],
]);
$pdo = $db->getConnection();
return $db;
} catch (Exception $e) {
$error = getError('Error connecting to DB.', $e->getMessage());
include '../app/templates/block-message.php';
exit();
return $error;
// include '../app/templates/block-message.php';
// exit();
}
// unknown database
} else {
@ -61,6 +64,6 @@ function connectDB($config, $database = '', $dbFile = '', $platformId = '') {
}
return $db;
// return $db;
}
?>

View File

@ -4,8 +4,13 @@ require '../app/classes/conference.php';
require '../app/classes/participant.php';
// connect to database
$db = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $platform_id);
$response = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $platform_id);
if ($response['db'] === null) {
$error = $response['error'];
include '../app/templates/block-message.php';
} else {
$db = $response['db'];
}
//
// dashboard widget listings

View File

@ -1,13 +1,24 @@
<?php
// 'notice' for all non-critical messages
// 'error' for errors
if (isset($_SESSION['error'])) {
echo "\t\t" . '<div class="error">' . $_SESSION['error'] . '</div>';
}
// 'error' for errors
// 'notice' for all non-critical messages
if (isset($_SESSION['notice'])) {
echo "\t\t" . '<div class="notice">' . $_SESSION['notice'] . '</div>';
}
// 'error' for errors
if (isset($error)) {
echo "\t\t" . '<div class="error">' . $error . '</div>';
}
// 'notice' for all non-critical messages
if (isset($_SESSION['notice'])) {
echo "\t\t" . '<div class="notice">' . $_SESSION['notice'] . '</div>';
}
?>