"php 7.1.x - mysqli_connect isn't defined (extension is turned on)" Code Answer



first off, a bit of into about the way that wampserver handles php.ini files. if you use phpinfo(), you may notice that the path to the loaded ini file is not the ini file in the php installation. it instead points to the apache installation.

but if you look at it, it's a 0kb symlink. what is actually is is a link to an ini file in the php installation. but it isn't the php.ini, it instead points to phpforapache.ini. so this:


is actually


so, you can ignore what is in the apache folder and focus on your ini files in the php folder. however, you can't ignore the php.ini. you need to correct both.

kudos to jon stirling to suggesting checking the loaded configuration file in phpinfo().

what i did

i installed php 7.1 from the php website, and forgot to transfer my ini files over from the php 7.0 installation. i instead used the default ini files provided by the php website.

that didn't work, because there are tweaks in the ini files that are needed to make php work with wamp. so i copied the two ini files over from my 7.0.x folder, and then it started working, mostly, except for the error with mysqli.

root cause of my problem

after scratching at this for an hour, fred -ii-'s last question finally got me to the answer. i had php trying to reference old extension files. here is why:

the php.ini file and the phpforapache.ini file, provided by wamp, both hard code some paths. for example, the extensions folder path for php 7.0.10 is coded as this:

extension_dir ="c:/wamp64/bin/php/php7.0.10/ext/"

i had copied the ini files over, but they were pointing to the extension folder for 7.0. the dll files for 7.0.x don't work with 7.1.x.


i went into the two files (php.ini phpforapache.ini) in the php 7.1.4 folder, and globally replaced all instances of the text "7.0.10" to "7.1.4". and now it's all working.

By Thomas Falkenberg on January 22 2022

Answers related to “php 7.1.x - mysqli_connect isn't defined (extension is turned on)”

Only authorized users can answer the Search term. Please sign in first, or register a free account.