You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows环境下PHP报Call to undefined function mysqli_connect()错误求助

Fixing "Call to undefined function mysqli_connect()" on Windows PHP

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 named info.php with this code:

    <?php phpinfo(); ?>
    

    Run it in your browser and look for the Loaded Configuration File line. If it shows (none), PHP isn't finding your php.ini. Move the file to the directory specified in the Configuration File (php.ini) Path line, or update your web server config (like Apache's httpd.conf) to point to your php.ini explicitly.

  • Set the correct extension_dir path
    This is a super common gotcha. Open your php.ini and find the extension_dir setting. For Windows, it should point to the ext folder 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.dll exists in your ext folder
    Head to your PHP directory's ext subfolder and make sure there's a file named php_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=mysqli works 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:02:23