Uncaught Error: Class 'mysqli' not found on Windows 10 with Apache 2.4, PHP 7.4

1.1k views Asked by At

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

enter image description here

php.ini directives

extension_dir = "ext"
extension=mysqli

Looking at the phpinfo, it seems like mysqlnd is loaded, but mysqli is not. I don't know how to get it loaded.

Question

How do I load mysqli module on Windows, when it seems like I already have directives in 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 in C:\php\php.ini

When setting up previous versions of PHP Configuration File Path used to be C:\php\php.ini. Move to C:\Windows seems to be new, and that is what threw me off. If someone can find a proper official docs or guide where this is explained or documented, I will appreciate it. I was not able to successfully find proper installation instructions for PHP just yet, and was going by memory of my previous experiences.

1

There are 1 answers

0
Dennis On

My Configuration File (php.ini) Path was blank, and for whatever reason, PHP was looking for php.ini file in C:\Windows, and not in C:\php, where I usually had it in the past. I moved my php.ini file into C:\Windows, and it seems like we are happy again.