Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Fatal Error: Class mysqli not fount  (Read 6996 times)

0 Members and 1 Guest are viewing this topic.

thebackup

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Fatal Error: Class mysqli not fount
« on: February 01, 2021, 06:38:21 am »

Hello! I've recently upgraded my Coppermine gallery from 1.5.46 to 1.6.10, with PHP 5.4.
I've followed the upgrading instructions carefully as outlined in here: https://coppermine-gallery.net/docs/curr/en/upgrading.htm

Ran the update.php script, and no problem. Able to log in and everything seems to look good. However, when I switch to PHP 7.4, I'm getting errors, specifically it says something like:

Code: [Select]
Fatal error: Uncaught Error: Class 'mysqli' not found in /home3/******/public_html/gallery/include/database/mysqli/dbase.inc.php:31
So I went into config.inc.php I changed 'dbtype' from 'mysqli' to 'mysql'. Still getting errors. Reverted it back to 'mysqli', restored the database to just before the update, and ran "update.php". Now I get this error message:

Fatal error: Uncaught Error: Class 'mysqli' not found in /home3/******/public_html/gallery/include/database/mysqli/dbase.inc.php:31 Stack trace: #0 /home3/******/public_html/gallery/include/init.inc.php(168): CPG_Dbase->__construct(Array) #1 /home3/******/public_html/gallery/update.php(23): include_once('/home3/******/p...') #2 {main} thrown in /home3/******/public_html/gallery/include/database/mysqli/dbase.inc.php on line 31

I can't really switch back to PHP 5.4 as my hosting removed it from a list of options. Any ideas as to what am I doing wrong?
Logged

thebackup

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Fatal Error: Class mysqli not fount
« Reply #1 on: February 01, 2021, 10:11:04 am »

I'd like to add that I contacted support for my hosting, and they reverted it back to PHP 5.4 and now it somehow works again.

I've done some googling and apparently the "class mysqli not found" error means the mysqli module isn't installed, but support told me it is already there for all versions of PHP. They also said that my site's code isn't compatible with PHP 7 - I'm really baffled by this part, as stated in above post I've upgraded to 1.6.10 with release notes saying "updated for compliance with PHP 8.01"

I'd like to leave it at PHP 5.4 but I was told that they will remove that version from the server within several months, meaning it'll default to PHP 7.4 and a broken gallery.
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Fatal Error: Class mysqli not fount
« Reply #2 on: February 01, 2021, 01:36:53 pm »

If you are getting that error message with PHP 7.4 then your hosting provider has not properly setup mysql with PHP 7.4.  The fault is theirs and they should correct it.

Just as a troubleshooting method, you could also try changing the 'dbtype' to 'pdo' in the Coppermine config to see what that does.
Logged

thebackup

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Fatal Error: Class mysqli not fount
« Reply #3 on: February 01, 2021, 06:43:12 pm »

So, I did some digging and I found this in my .htaccess file:
Code: [Select]
#AddHandler application/x-httpd-php54 .php
<IfModule mod_suphp.c>
    suPHP_ConfigPath /opt/php54/lib
</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

I commented out the PHP 5.4 stuff and now I get this (dbtype "mysqli"):
Code: [Select]
Coppermine critical error:
Unable to connect to database !

MySQLi said: :

Changing it to "pdo" gives me this:
Fatal error: Uncaught Error: Call to a member function errorInfo() on null in /home3/******/public_html/gallery/include/database/pdo/dbase.inc.php:71 Stack trace: #0 /home3/******/public_html/gallery/include/init.inc.php(171): CPG_Dbase->getError() #1 /home3/******/public_html/gallery/index.php(22): require('/home3/******/p...') #2 {main} thrown in /home3/******/public_html/gallery/include/database/pdo/dbase.inc.php on line 71

And somehow commenting out the PHP 7.4 in .htaccess and uncommenting PHP 5.4 will make it work again (mysqli, pdo gives errors).
Logged

thebackup

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Fatal Error: Class mysqli not fount
« Reply #4 on: February 15, 2021, 05:36:54 am »

Alright, I solved my issue, finally got my gallery to work with PHP 7.4! Here's what I did:

Because the "Coppermine critical error: Unable to connect to database!" message wasn't outputting anything useful, I added this line in "include/init.inc.php" just before it connects to the database (from: https://stackoverflow.com/questions/18457821/how-to-make-mysqli-throw-exceptions-using-mysqli-report-strict):

Code: [Select]
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
I get a blank page, but I checked "error_log" on my gallery's installation folder, and I found this:

Code: [Select]
PHP Fatal error:  Uncaught mysqli_sql_exception: The server requested authentication method unknown to the client
Did some googling with that message and I found this: https://stackoverflow.com/questions/1340488/mysql-php-incompatibility
Changed the MySQL database password and set it accordingly in "config.inc.php" and now it works!
Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 20 queries.