WordPress.org

Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#52001 closed defect (bug) (duplicate)

PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect()

Reported by: ipajen Owned by:
Milestone: Priority: normal
Severity: blocker Version: 5.6
Component: Database Keywords:
Focuses: Cc:

Description

WP 5.6 and after upgrading to PHP 8 from PHP 7.4 following error occurs:

(removed paths)

[STDERR] PHP
Fatal error:  Uncaught Error: Call to undefined function mysql_connect()
in
wp-db.php:1688
Stack trace:
#0
wp-db.php(632):
wpdb->db_connect()
#1
load.php(527):
wpdb->__construct()
#2
wp-settings.php(124):
require_wp_db()
#3
wp-config.php(88):
require_once('/home/khaotipth...')
wp-load.php(37):
require_once('/home/khaotipth...')
#5
wp-blog-header.php(13):
require_once('/home/khaotipth...')
index.php(17):
require('/home/khaotipth...')
#7 {main}
   thrown in
wp-db.php
on line 1688

Disabled all plugins and changed to Twenty Twenty-One (twentytwentyone).

https://wordpress.org/support/topic/php-8-and-wp-5-6-php-fatal-error-uncaught-error-call-to-undefined-function/?view=all#post-13766567

(If I disable mysqli in 7.4 the same error occurs.)

My first bug report to WP so be kind ;)

Change History (4)

#1 @hellofromTonya
12 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Summary changed from WP 5.6 and PHP8 > PHP Fatal error: Uncaught Error: Call to undefined function to PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect()

Hello @ipajen,

Welcome to Trac!

I'm sorry you are experiencing issues with WordPress 5.6.

The mysql_connect() function was deprecated in PHP 5.5 and removed in 7.0.0 see the PHP documentation.

Since 3.9, WordPress uses mysqli on PHP 5.5 or later instead of the deprecated mysql extension. See this post for more context: MySQL in WordPress 3.9.

In #51988 related ticket, Sergey makes the following suggestion:

I would suggest checking that the mysqli extension is available and the WP_USE_EXT_MYSQL constant is not defined in wp-config.php.

I'm closing this ticket as this issue is not due to WordPress core software.

#2 @desrosj
12 months ago

  • Resolution changed from invalid to duplicate

Duplicate of #51988.

#3 @ipajen
12 months ago

@hellofromTonya @desrosj
Thank you, I checked the wp-config.php and I did not have the WP_USE_EXT_MYSQL and mysqli is enabled in the extension.

I was using PHP 7.4 (where the mysql_connect() was removed already and everything worked fine) until before upgrading to PHP 8. No changes has been made except upgrading to PHP 8. So the question is why does it want to use mysql_connect instead of correct mysqli. Got 3 word press installltions on same hosting and all has the same problem, one of is very newly installed.

#4 @desrosj
12 months ago

@ipajen There is a reason for PHP 8 surfacing the issue, which I'll explain on the other ticket in an effort to keep conversation in one location.

Note: See TracTickets for help on using tickets.