I just upgraded to PHP 7 only to find that WordPress 4.8.1 (latest version) still uses mysql_connect in the wp-db.php module, but mysql_connect has been deprecated.
The following code is taken from wp-db-php, lines 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);
}
Here is the output when I try to run my program:
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in D:\ApacheHtdocs\ConneXions\wp-includes\wp-db.php:1570
Stack trace:
#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} thrown in D:\ApacheHtdocs\ConneXions\wp-includes\wp-db.php on line 1570
I can't believe that WordPress says it recommends PHP 7, but it doesn't work with it. What am I missing here?
mysql_connect
is only used as a fallback whenmysqli
is not detected. It would appear you have neithermysqli
ormysql
installed (mysqli
is recommended,mysql
is deprecated )