Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#52001 closed defect (bug) (duplicate)

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

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


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

(removed paths)

Fatal error:  Uncaught Error: Call to undefined function mysql_connect()
Stack trace:
#7 {main}
   thrown in
on line 1688

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

(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
4 years 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
4 years ago

  • Resolution changed from invalid to duplicate

Duplicate of #51988.

#3 @ipajen
4 years 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
4 years 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.