So I never use CodeIgniter before, but I found an online judge app in github that just need to be deployed. I found that here: https://github.com/mjnaderi/Sharif-Judge
. I try to run it by following all the instruction, but I still get database error. I try it for hours by changing php version, try it on docker, editingthe config but still the same error. One time, I succeed but I don't even know how. That happen in virtual machine unfortunately. I found this one error that always come up:
Fatal error: Uncaught mysqli_sql_exception: Table 'ojdatabase.shj_sessions' doesn't exist in /var/www/online-judge/system/database/drivers/mysqli/mysqli_driver.php:212
At first I thought that I have something wrong at my config/database.php, but after some re-check I found nothing wrong here. I only change this, based on the instruction:
/* Enter database connection settings here: */
'dbdriver' => 'mysqli', // database driver (mysqli, postgre)
'hostname' => '127.0.0.1', // database host
'username' => 'dbuser', // database username
'password' => 'an1m3w1bu', // database password
'database' => 'ojdatabase', // database name
'dbprefix' => 'shj_', // table prefix
/**********************************************/
I already checked the dbuser access and it has access to ojdatabase. The password is also correct. I check the access to application/cache/Twig
, and give all access to it. I also give 755 access to the project folder. I also make sure if php-mysqli installed.
I try to check if php can access my database. So i create ver.php in root of my codeigniter projectlike this:
<?php
$databaseHost = "localhost"; // Replace with your database host
$databaseName = "your_database"; // Replace with your database name
$databaseUser = "your_username"; // Replace with your database username
$databasePassword = "your_password"; // Replace with your database password
// Attempt to establish a database connection
$connection = mysqli_connect($databaseHost, $databaseUser, $databasePassword, $databaseName);
// Check the connection
if (!$connection) {
die("Database connection failed: " . mysqli_connect_error());
}
echo "Database connection successful!";
// Close the connection (optional)
mysqli_close($connection);
?>
And get that connection successful. So I checked my config again, and found this session config:
$config['sess_driver'] = 'cookie';
$config['sess_valid_drivers'] = array();
$config['sess_cookie_name'] = 'shjsession';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
From the error message I think the program tried to created a table shj_sessions
but fail and then crashing the program?
Are my assumption correct? Or can anyone help with some hint about this error?
source https://stackoverflow.com/questions/77039950/codeigniter-cant-create-session-table
No comments:
Post a Comment