我刚刚升级到PHP 7,只是发现WordPress 4.8.1(最新版本)仍在wp-db.php模块中使用mysql_connect,但是已弃用mysql_connect。
以下代码摘自wp-db-php,行1567-1571:
if ( WP_DEBUG ) {
$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
} else {
$this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this>dbpassword,
$new_link, $client_flags);
}
这是我尝试运行程序时的输出:
致命错误:未捕获错误:调用D:\ ApacheHtdocs \ ConneXions \ wp-includes \ wp-db.php:1570中未定义的函数mysql_connect()
堆栈跟踪:
#0 D:\ ApacheHtdocs \ ConneXions \ wp-includes \ wp- db.php(658):wpdb-> db_connect()
#1 D:\ ApacheHtdocs \ ConneXions \ wp-includes \ load.php(404):wpdb-> __ construct('root',``,'connexions',' localhost')
#2 D:\ ApacheHtdocs \ ConneXions \ wp-settings.php(106):require_wp_db()
#3 D:\ ApacheHtdocs \ ConneXions \ wp-config.php(104):require_once('D:\ ApacheHtdocs。 ..')
#4 D:\ ApacheHtdocs \ ConneXions \ wp-load.php(37):require_once('D:\ ApacheHtdocs ...')
#5 D:\ ApacheHtdocs \ ConneXions \ wp-blog-header.php (13):require_once('D:\ ApacheHtdocs ...')
#6 D:\ ApacheHtdocs \ ConneXions \ index.php(17):require('D:\ ApacheHtdocs ...')
#7 {main}放在D:\ ApacheHtdocs \ ConneXions \ wp-includes \ wp-db中。第1570行的php
我不敢相信WordPress会说它推荐PHP 7,但是它不起作用。我在这里想念什么?
mysql_connect
仅在mysqli
未检测到时用作后备。看来您没有安装mysqli
或未mysql
安装(mysqli
建议mysql
过时)