Windows环境下PHP报Call to undefined function mysqli_connect()错误求助
Hey there, let's work through this error step by step—you've already taken the first big step by renaming the php.ini file, so we just need to nail down a few more key details.
Verify your php.ini is actually being loaded
Sometimes PHP doesn't pick up the php.ini you modified. Create a simple script namedinfo.phpwith this code:<?php phpinfo(); ?>Run it in your browser and look for the
Loaded Configuration Fileline. If it shows(none), PHP isn't finding your php.ini. Move the file to the directory specified in theConfiguration File (php.ini) Pathline, or update your web server config (like Apache's httpd.conf) to point to your php.ini explicitly.Set the correct
extension_dirpath
This is a super common gotcha. Open your php.ini and find theextension_dirsetting. For Windows, it should point to theextfolder inside your PHP directory. Use either a relative path (if PHP's folder is in your system PATH) or an absolute path with forward slashes:; Use relative path if PHP's folder is in PATH extension_dir = "ext" ; Or absolute path (replace with your actual PHP folder) extension_dir = "C:/Program Files/php/ext"Without this set correctly, PHP can't find the mysqli extension file even if you uncommented
extension=mysqli.Check if
php_mysqli.dllexists in yourextfolder
Head to your PHP directory'sextsubfolder and make sure there's a file namedphp_mysqli.dll. If it's missing, you probably downloaded a stripped-down PHP package. Grab the full version from the official PHP site (match your architecture—x86/x64—and thread safety setting based on your web server: Apache uses thread-safe, Nginx uses non-thread-safe).Restart your web server
Changes to php.ini only take effect after you restart Apache, Nginx, or PHP-FPM (if you're using it). Don't skip this step—even if you made all the right edits, the old config will still be running until you restart.Double-check the extension line in php.ini
For most modern PHP versions (7.4+),extension=mysqliworks fine, but if you're on an older version, try using the full filename:extension=php_mysqli.dll
Bonus tip: If you're using an integrated environment like XAMPP or WAMP, don't hunt for php.ini manually—use the environment's control panel to open the correct configuration file. These tools often have multiple php.ini copies, so editing the wrong one won't help.
内容的提问来源于stack exchange,提问作者Potatoboy

