-1

I know the dl() function no longer works and I have tried to follow every directive I found but still I can't get the mysqli extension to work with my php.

In phpinfo(), the "Loaded Configuration File" is "C:\MAMP\conf\php8.0.1\php.ini". I have opened this file and I have this on lines 543 and 544

; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\MAMP\bin\php\php8.0.1\ext\"

This also matches with what I have from phpinfo() under "extension_dir".

I have also checked the specified folder and it contains a file named "php_mysqli.dll" among many other dll files. Also, further down in the php.ini file mentioned above, I have this on lines 671 to 673:

extension=php_exif.dll
extension=php_mysqli.dll
extension=php_pdo_sqlite.dll 

(The only exception is that in all of them, the word 'extension' is italicized; but that's the same thing with every other key in the file that is not commented out.) I have also restarted my server and in fact my entire system, just to be sure, but still it's not being loaded. I check using phpinfo() and extension_loaded('mysqli'). I'm running php 8 on Windows 11.

I also checked out this question and I located PHPIniDir in my Apache24 configuration file (httpd.conf) but its value is "C:\MAMP\conf\php8.0.1\php.ini" which is the "Loaded Configuration File" my php uses. I'm not sure but I don't think I should edit that.

Since the mysqli extension is clearly not commented out, and everything else seems to be in place, why is it not being loaded? Is there something else I may be missing?

Edit: This was resolved when I changed the value of extension_dir in the php.ini file from "C:\MAMP\bin\php\php8.0.1\ext\" to "C:\php\ext". The extensions exist in both folders, so I just guessed that the former was where MAMP wanted it to read from while the latter is where it was initially supposed to read from. Plus that's also where I initially installed PHP before ever installing MAMP. Anyways, not sure of the exact reason why it worked but it did.

Lucky Uche
  • 21
  • 5
  • What error message do you see? What does `extension_loaded('mysqli')` show? It could be that you didn't start your `mysql` server. Based on the path you provided I'm assuming you are using MAMP which I believe `Mysqli` comes bundled with – Rain Aug 18 '22 at 10:45
  • Instead of true, it was returning false, indicating that the extension was not yet loaded. Yes, I was using MAMP. Didn't know it came with its own mysqli but I guess that makes sense as I was using MAMP's mysqli instead of PHP's mysqli. I don't really understand it but I'm glad it's working now. – Lucky Uche Aug 19 '22 at 16:22

1 Answers1

-2

Changing the value of 'extension_dir' in the php.ini file to "C:\php\ext" solved my problem.

Edu
  • 1