WordPress Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /wp-includes/wp-db.php:1570

I encountered this problem upgrading from PHP 5 to PHP 7 (on Windows). The problem was mysqli PHP extension was not enabled. If mysqli is not available WordPress 5+ detects this and will instead attempt to connect to the database with deprecated mysql_connect() calls. This leads to a very misleading error message about mysql_connect() function not being available (since we don’t want this function).

In php.ini make sure extension_dir is set (use full directory name) and mysqli extension is enabled

extension_dir = "C:\php-7.3.10\ext"
...
extension=mysqli

To double check what extensions are active you can run the following code

<pre>
<?php print_r(get_loaded_extensions()); ?>
</pre>

Leave a Comment