Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebCalendar Upgrade: Your mysqli database named 'usr_p663408_1' is empty and needs tables created. but tables and data exists. #471

Open
max951 opened this issue Mar 7, 2024 · 4 comments

Comments

@max951
Copy link

max951 commented Mar 7, 2024

I tried to update from 1.3.0 to 1.9.12

System Status said:
Settings storage: includes/settings.php
Database connection: Can connect
Number of admin users: 0
WebCalendar version (installer): v1.9.12
WebCalendar version (database):
PHP version: Supported (8.1.26)

In step 'Create/Update Tables' the wizard says:
Your mysqli database named 'usr_db' is empty and needs tables created.

But all tables and data from V1.3.0 already exists.

Query SELECT COUNT(*) FROM webcal_config;
returns COUNT(*) = 163

Query SELECT COUNT(*) FROM webcal_user WHERE cal_is_admin = 'Y'
returns COUNT(*) = 2

So, why System Status says Number of admin users: 0 ?
And why does the wizard want to create new tables instead of upgrading from version ZZZ ?

In file "install/install_dbtables.php" line 15 is the value of variable $emptyDatabase is true. I think it should be false.
But I can can not figure out why this is so.

@max951
Copy link
Author

max951 commented Mar 7, 2024

Perhaps this will lead someone to the solution:

If I activate line 344 in the file includes/dbi4php.php
echo "Error: " . $e->getMessage() . "<br>";
I get the message Error: No database selected

But in the step before Create Database the correct database is displayed: Your mysqli database named 'usr_p663408_1' exists. You may go on to the next step.

@max951 max951 changed the title WebCalendar Upgrade: Your mysqli database named 'usr_db' is empty and needs tables created. but tables and data exists. WebCalendar Upgrade: Your mysqli database named 'usr_p663408_1' is empty and needs tables created. but tables and data exists. Mar 7, 2024
@max951
Copy link
Author

max951 commented Mar 12, 2024

I've done the trick:
In file includes/dbi4php.php i added a line with "select_db($db_connection_info['database'])" at line 340

before:

 } elseif( strcmp( $GLOBALS['db_type'], 'mysqli' ) == 0 ) {
    $found_db_type = true;
    try {
      $res = $GLOBALS['db_connection']->query( $sql );
    } catch (Exception $e) {

after:

 } elseif( strcmp( $GLOBALS['db_type'], 'mysqli' ) == 0 ) {
    $found_db_type = true;
    try {
      $GLOBALS['db_connection']->select_db($db_connection_info['database']);
      $res = $GLOBALS['db_connection']->query( $sql );
    } catch (Exception $e) {

It would be fine, if someone could add this into the master.

Thanks

@max951 max951 mentioned this issue Mar 12, 2024
@s22-tech
Copy link

s22-tech commented Apr 28, 2024

Good catch, Max! This worked for me, as well. I can't believe that anybody (running MySQL) has been able to install this script. The only error message I received was "Error executing query" which didn't help at all.

Thank you!

@mada0068
Copy link

Worked for me!!!! Thanks

I've done the trick: In file includes/dbi4php.php i added a line with "select_db($db_connection_info['database'])" at line 340

before:

 } elseif( strcmp( $GLOBALS['db_type'], 'mysqli' ) == 0 ) {
    $found_db_type = true;
    try {
      $res = $GLOBALS['db_connection']->query( $sql );
    } catch (Exception $e) {

after:

 } elseif( strcmp( $GLOBALS['db_type'], 'mysqli' ) == 0 ) {
    $found_db_type = true;
    try {
      $GLOBALS['db_connection']->select_db($db_connection_info['database']);
      $res = $GLOBALS['db_connection']->query( $sql );
    } catch (Exception $e) {

It would be fine, if someone could add this into the master.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants