You run your PHP project and instead of connecting to the database it dies immediately with a fatal error saying mysqli_connect() does not exist. This is different from a normal connection problem. PHP is telling you the function itself is missing, which means the MySQLi extension is switched off. Turning it on is a two minute fix once you know where to look.
Why this happens (and why it is not a database problem)
PHP has a core set of functions, and then a set of optional extensions that add more functions. Talking to a MySQL database is handled by an extension called mysqli. If that extension is not loaded, then functions like mysqli_connect(), mysqli_query(), and mysqli_fetch_assoc() simply do not exist as far as PHP is concerned, and calling them throws this fatal error.
This is why the error is worded differently from a normal connection failure. A connection failure means the function ran but could not reach the database. An “undefined function” error means the function was never available to run in the first place. The fix is to switch the extension on.
In a standard XAMPP or WAMP install, mysqli is enabled by default, so you usually only hit this on a custom PHP setup, a fresh Linux server, or after someone edited the configuration. If you are on default XAMPP and still see it, double check you are editing the php.ini that XAMPP actually uses, covered in step 1.
Step 1: find your active php.ini file
The single biggest reason this fix “does not work” is editing the wrong php.ini. Computers often have more than one. To find the exact file PHP is using, create a file called info.php with this content and open it in your browser:
On the page that loads, look for the row labeled Loaded Configuration File. The path shown there is the only php.ini that matters. Edit that one. Any other php.ini on your system is ignored.
Delete info.php when you are done. The phpinfo() page reveals details about your server that should not be public on a live site.
Step 2: enable the mysqli extension
Open the php.ini path from step 1 in a text editor. Use find to search for mysqli. You are looking for a line like this:
;extension=mysqli
The semicolon at the start is a comment marker. It is switching the extension off. Remove the semicolon so the line reads:
extension=mysqli
Save the file. On some older configurations the line may read ;extension=php_mysqli.dll on Windows. The fix is the same: remove the leading semicolon.
Step 3: restart the server
PHP only reads php.ini when it starts, so your change does nothing until you restart. In the XAMPP or WAMP control panel, stop Apache and start it again. The extension now loads, the function exists, and the fatal error is gone.
Restarting Apache is required for almost any php.ini change to take effect. If you ever edit php.ini and nothing changes, the missing restart is usually why.
Fixing it on Linux servers
On a Linux server, extensions are usually installed as system packages rather than toggled in a file. Install the MySQLi extension for your PHP version and restart the web server. The package name follows your PHP version, for example:
# Replace 8.3 with your actual PHP version
sudo apt install php8.3-mysqli
sudo systemctl restart apache2
If you use PHP FPM with Nginx, restart the FPM service instead, for example sudo systemctl restart php8.3-fpm. After installing the package and restarting, the function becomes available.
How to verify the extension is loaded
To confirm the fix worked before running your full project, reload the phpinfo() page and search the page for mysqli. If the extension is loaded, you will see a dedicated mysqli section with its settings. If that section is present, the function exists and your connection code will run.
You can also check quickly from the command line:
# Lists loaded extensions, should include mysqli
php -m | grep mysqli
Frequently asked questions
What is the difference between mysqli and mysql functions?
The old mysql_ functions were removed from PHP years ago and no longer exist in any current version. If your code uses mysql_connect() instead of mysqli_connect(), that is a separate, larger problem: the code is outdated and needs updating to mysqli or PDO. This guide is about the modern mysqli extension.
I removed the semicolon but still get the error. Why?
Two usual reasons. Either you edited a php.ini that PHP does not actually use, so verify the Loaded Configuration File path with phpinfo(), or you did not restart Apache after saving. Both are required for the change to take effect.
Should I use mysqli or PDO for a new project?
Either works well. PDO supports more database types and has a cleaner interface for prepared statements, while mysqli is MySQL specific and slightly simpler. For fixing a downloaded project that already uses mysqli, just enable the extension rather than rewriting everything.
Does this same fix apply to the pdo_mysql extension?
Yes, the process is identical. If your project uses PDO and you get an undefined PDO error, find the ;extension=pdo_mysql line in php.ini, remove the semicolon, and restart Apache. Same steps, different extension name.
Once the extension is loaded, your database functions exist and the project runs normally. From here, any project in the PHP source code library will connect as expected.

