You haven't told us which OS you are using. But since you've already mentioned apt-get
then I'll assume that you're using something similar to Ubuntu or Debian. These have a relatively similar configuration setup.
Check 1
The package php-mysql
should be dependent on php7.2-mysql
or similar so firstly check that this is installed eg:
dpkg --list | grep 'php.*mysql'
ii php-mysql 2:7.2+69ubuntu1 all MySQL module for PHP [default]
ii php7.2-mysql 7.2.19-0ubuntu0.19.04.1 amd64 MySQL module for PHP
Do take a note of which version you have installed, if not 7.2 like my setup you will need to change later checks to match your version.
Check 2
I've just looked at my Ubuntu 19.04 setup and mysqli has it's own shared library currently installed to belonging to the php7.2-mysql
package and installed to /usr/lib/php/20170718/mysqli.so
.
find /usr/lib/php -name mysqli.so
Check 3
For PHP to use the module, it needs to be instructed to load it. Depending on the way you have setup PHP to run you may need to look in a different place. But for me, running PHP 7.2 under phpfpm, the instruction to
load mysqli is located in: /etc/php/7.2/fpm/conf.d/20-mysqli.ini
.
Check to see if you have the module loaded with:
grep mysqli.so /etc/php/7.2/*/conf.d/*
/etc/php/7.2/cli/conf.d/20-mysqli.ini:extension=mysqli.so
/etc/php/7.2/fpm/conf.d/20-mysqli.ini:extension=mysqli.so
Make sure that whichever way you are using PHP` is configured to load the module. If it is not configured to do so then you should be able to add back the configuration:
cd /etc/php/7.2/fpm/conf.d
ln -s ../../mods-available/mysqli.ini 20-mysqli.ini
Check 3 is the most likly to be the cause given the evidence you've shown, but it's also the mos easy to make a mistake on.
Uncaught Error: Class mysqli not found on Windows 10 with Apache 2.4, PHP 7.4
Questions : Uncaught Error: Class mysqli not found on Windows 10 with Apache 2.4, PHP 7.4
2022-10-09T11:00:03+00:00 2022-10-09T11:00:03+00:00
719
System/Software:
- Windows 10 Pro 64 bit, Version 1909
- httpd-2.4.43-win64-VS16
- php-7.4.5-Win32-vc15-x64
- mysql-installer-web-community-8.0.20.0
PHP Script
if [!function_exists['mysqli_init'] && !extension_loaded['mysqli']] {
echo 'We don\'t have mysqli!!!';
} else {
echo 'Phew we have it!';
}
Yields: We don't have mysqli!!!
phpinfo
php.ini directives
extension_dir = "ext"
extension=mysqli
Looking at the phpinfo, it seems like anycodings_apache mysqlnd is loaded, but mysqli is not. I anycodings_apache don't know how to get it loaded.
Question
How do I load mysqli module on Windows, when anycodings_apache it seems like I already have directives in anycodings_apache php.ini to have it be loaded?
Update - I found these
-
phpinfo[]
reports: Configuration File [php.ini] Path:C:\Windows
-
phpinfo[]
reports: Loaded Configuration File:[none]
- My
php.ini
file is located inC:\php\php.ini
When setting up previous versions of PHP anycodings_apache Configuration File Path used to be anycodings_apache C:\php\php.ini. Move to C:\Windows seems to anycodings_apache be new, and that is what threw me off. If anycodings_apache someone can find a proper official docs or anycodings_apache guide where this is explained or documented, anycodings_apache I will appreciate it. I was not able to anycodings_apache successfully find proper installation anycodings_apache instructions for PHP just yet, and was going anycodings_apache by memory of my previous experiences.
Total Answers 1
31
Answers 1 : of Uncaught Error: Class mysqli not found on Windows 10 with Apache 2.4, PHP 7.4
My Configuration File [php.ini] Path was anycodings_apache-modules blank, and for whatever reason, PHP was anycodings_apache-modules looking for php.ini file in C:\Windows, anycodings_apache-modules and not in C:\php, where I usually had anycodings_apache-modules it in the past. I moved my php.ini file anycodings_apache-modules into C:\Windows, and it seems like we anycodings_apache-modules are happy again.
0
2022-10-09T11:00:03+00:00 2022-10-09T11:00:03+00:00Answer Link
mRahman