Fatal error with mysql_connect after upgrading to PHP 7

When you update your WordPress site under PHP 7, the following errors may appear :

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in ...wp-includes/wp-db.php:1665
Stack trace: #0 ...wp-includes/wp-db.php(632): wpdb->db_connect() #1 ...wp-includes/load.php(425)
Fatal error: Uncaught Error: Call to undefined function wp_kses_normalize_entities() in .../wp-includes/formatting.php:4316
Stack trace: #0 .../wp-includes/class-wp-fatal-error-handler.php(190)

What can be done to solve this problem?

Depending on the origin of the error, there are several solutions:

  • Contact your web host and ask if mysqli extensions are enabled.
  • Check that you have mysqi enabled on your hosting:
    $var_mysqli = function_exists('mysqli_connect'); var_dump($var_mysqli);
  • Test your connection with mysqli :
    $mysqli_connection = new MySQLi('nom_d_hôte', 'nom_utilisateur', 'mot_de_passe', 'nom_de_la_base_de_données');
  • Check your wp-config.php file and verify that the following variable :
    define(‘WP_USE_EXT_MYSQL’, false);
    is set to “false”.

Still stuck ? You can contact an expert.

Leave a Comment

Your email address will not be published.

You may also like
gdpr
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.