最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

apache - Call to undefined function mysql_connect() After upgrading PHP 7.1 to 7.3

programmeradmin1浏览0评论

I host my own WP site on a Debian/Raspbian buster server.

I upgraded PHP 7.1 to 7.3 and the site broke.

I can't understand why it broke because mysql_connect() is deprecated for 7.x (though wp-db.php seems to use it extensively - while WP nags you to upgrade to 7.3). So I looked to enabling the various modules in the fresh 7.3 install php.ini. MySQLi was commented out, so I enabled that (and a few others) but still get the same error.

Call to undefined function mysql_connect()... wp-db.php on line 1643

which is...

    if ( WP_DEBUG ) {
  1643                  $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );

Php info references MySQLi several times so I'm assuming it's running. The same for mysqlnd.

I know this question gets asked a lot. But I have tried just about everything out there.

How can I get my site working again on 7.3?

Edit: I tried disabling plugins by renaming the dir and got the same result. I suspect the issue is my 7.3 PHP config, since 7.0 worked fie.

I host my own WP site on a Debian/Raspbian buster server.

I upgraded PHP 7.1 to 7.3 and the site broke.

I can't understand why it broke because mysql_connect() is deprecated for 7.x (though wp-db.php seems to use it extensively - while WP nags you to upgrade to 7.3). So I looked to enabling the various modules in the fresh 7.3 install php.ini. MySQLi was commented out, so I enabled that (and a few others) but still get the same error.

Call to undefined function mysql_connect()... wp-db.php on line 1643

which is...

    if ( WP_DEBUG ) {
  1643                  $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );

Php info references MySQLi several times so I'm assuming it's running. The same for mysqlnd.

I know this question gets asked a lot. But I have tried just about everything out there.

How can I get my site working again on 7.3?

Edit: I tried disabling plugins by renaming the dir and got the same result. I suspect the issue is my 7.3 PHP config, since 7.0 worked fie.

Share Improve this question edited Sep 3, 2019 at 11:11 square_eyes asked Sep 3, 2019 at 10:54 square_eyessquare_eyes 1152 silver badges10 bronze badges 1
  • 1 That error occurred in WP Core, have you made changes to WP itself? Is this a super old version? Current WP has different code on those lines github/WordPress/WordPress/blob/master/wp-includes/… – Tom J Nowell Commented Sep 3, 2019 at 11:31
Add a comment  | 

2 Answers 2

Reset to default 2

I mean your php.ini is changed, check for the entry extension=php_mysqll.dll.

(If you has no knowledge where is your used php.ini - see https://stackoverflow/questions/8684609/dude-wheres-my-php-ini)

Is this entry active, has no ; before the string. After change of the php.ini you need a restart of mysql, like sudo /etc/init.d/mysql restart.

Also a note, check that mysql is installed for the newer php version, maybe via console or the phpinfo().

sudo apt-get install mysql-server mysql-common php7.3 php7.3-mysql

Your problem is either:

  • very old WordPress
  • custom modifications to WP Core

Update to a newer version of WordPress to resolve the problem

For example, if we look at the current WP source code, it doesn't use mysql_connect and hasn't for years:

https://github/WordPress/WordPress/blob/master/wp-includes/wp-db.php#L1638

            if ( WP_DEBUG ) {
                mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
            } else {
                // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
                @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
            }

It won't be enough to just change mysql_connect to mysqli_real_connect though, as there are other changes. So update to the latest WordPress

发布评论

评论列表(0)

  1. 暂无评论