Unknown column 'wp_' in 'field list' when running WordPress on PHP 8.1
Asked Answered
D

3

7

Is it possible to run Wordpress on PHP 8.1 right now? I have installed PHP 8.1 in XAMPP, but I can't get Wordpress to work. I get this error message:

[23-Nov-2021 18:44:43 UTC] PHP Fatal error: Uncaught mysqli_sql_exception: Unknown column 'wp_' in 'field list' in C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-includes\wp-db.php:2056 Stack trace: #0 C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-includes\wp-db.php(2056): mysqli_query(Object(mysqli), 'SELECT wp_') #1 C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-includes\wp-db.php(1945): wpdb->do_query('SELECT wp') #2 C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-admin\setup-config.php(317): wpdb->query('SELECT wp_') #3 {main} thrown in C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-includes\wp-db.php on line 2056 [23-Nov-2021 18:45:45 UTC] PHP Fatal error: Uncaught mysqli_sql_exception: Unknown column 'wp_' in 'field list' in C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-includes\wp-db.php:2056

I have verified that PHP 8.1 is being served to this folder and I can run PDO and mysqli commands that successfully create and modify local databases.

Divertimento answered 23/11, 2021 at 20:26 Comment(2)
might this help?Aga
yes, it works fine on 8.0.3 and 8.0.11Divertimento
D
10

As of November 2021* WordPress is not yet fully compatible with PHP 8.1. The WordPress 5.9 release that is planned to be available on 25th January 2022 should be compatible with PHP 8.1.

For the time being, please use PHP 8.0 with WordPress to avoid weird bugs.

* PHP 8.1 was released on 25th November 2021

Dennis answered 23/11, 2021 at 21:49 Comment(0)
S
3

For anyone who reaches this in the next couple days before Wordpress 5.9 comes out, I was able to get 5.8.3 working on PHP 8.1 by making a quick change to wp-includes/wp-db.php. I added this line after if ( $this->use_mysqli ) in the db_connect method (line 1630):

mysqli_report(MYSQLI_REPORT_OFF);

This change is one made in Wordpress 5.9 itself, so should be fine.

Subtlety answered 22/1, 2022 at 23:42 Comment(1)
This does not solve the problemMeteor
D
0

@/SergeyBiryukov has pushed a bug fix which should be available in the next version of WordPress. If you're having this challenge, you can suppress these errors by opening wp-admin/setup-config.php and replacing the following lines.

Replace

 $errors = $wpdb->hide_errors();

With

$errors = $wpdb->suppress_errors();

And Replace

$wpdb->show_errors( $errors );

With

$wpdb->suppress_errors( $errors );
Dewdrop answered 22/10, 2022 at 21:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.