Support » Fixing WordPress » Fatal error with WordPress Update

  • Hi All, We are having a “Critical error message” on the wordpress website most likey to be caused by WordPress 5.8 upgrade. Debug code as below:

    Fatal error: Uncaught Error: Call to undefined function mysql_connect() in
    /var/www/website/wp-includes/wp-db.php:1685 Stack trace: #0
    /var/www/website/wp-includes/wp-db.php(632): wpdb->db_connect() #1
    /var/www/website/wp-includes/load.php(545): wpdb->__construct('wordpress_65', 'v24ZuPNr1_', 'client_5fc0585_...', 'localhost:3306') #2 
    /var/www/website/wp-settings.php(124): require_wp_db() #3
    /var/www/website/wp-config.php(108): require_once('/var/www/vhosts...') #4
    /var/www/website/wp-load.php(37): require_once('/var/www/vhosts...') #5
    /var/www/website/wp-admin/admin.php(34): require_once('/var/www/vhosts...') #6
    /var/www/website/wp-admin/index.php(10): require_once('/var/www/vhosts) #7
    {main} thrown in /var/www/website/wp-includes/wp-db.php on line 1685

    We have tried turning off plugins and themes as suggested by many online, but it didn’t help. Looked at PHP settings too, it’s mysqli enabled, etc.

    We have restored the website to the previous version and is working fine now.

    Can you please suggest what to do?
    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Did also check that define('WP_USE_EXT_MYSQL', true); is not defined in wp-config https://wordpress.org/support/topic/php-fatal-error-uncaught-error-call-to-undefined-function-mysql_connect-in/#post-10569776 ?

    • This reply was modified 1 day, 9 hours ago by glendaviesnz.
    • This reply was modified 1 day, 9 hours ago by glendaviesnz.
    Thread Starter digilscape

    (@digilscape)

    @glendaviesnz – Thanks for your reply. Yes, have checked that. That line is not there in the config file.

    Hello,

    I think you should check the enviroment and the php functions before the upgrade.
    Try to modify the wp-includes/wp-db.php file:
    (from line 612)

    original:

    // Use ext/mysqli if it exists unless WP_USE_EXT_MYSQL is defined as true.
    		if ( function_exists( 'mysqli_connect' ) ) {
    			$this->use_mysqli = true;
    
    			if ( defined( 'WP_USE_EXT_MYSQL' ) ) {
    				$this->use_mysqli = ! WP_USE_EXT_MYSQL;
    			}
    		}

    for the check:

    // Use ext/mysqli if it exists unless WP_USE_EXT_MYSQL is defined as true.
    echo "checking mysqli ... \n";
    		if ( function_exists( 'mysqli_connect' ) ) {
    			$this->use_mysqli = true;
    echo "mysqli found ... \n";
    			if ( defined( 'WP_USE_EXT_MYSQL' ) ) {
    				$this->use_mysqli = ! WP_USE_EXT_MYSQL;
    echo "disable mysqli \n";
    			}
    		}

    After it you will see (on a reloaded page) the statuses of the checking functions…

    Tom Miletics

    Developer
    You can contact me privately:
    http://www.mile.hu

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.