Title: $wpdb bug with PHP &gt; = 8?
Last modified: May 14, 2024

---

# $wpdb bug with PHP > = 8?

 *  [Daniel Lemes](https://wordpress.org/support/users/daniel_iceman/)
 * (@daniel_iceman)
 * [2 years ago](https://wordpress.org/support/topic/wpdb-bug-with-php-8/)
 * For a long time, I’ve been using a function to filter user’s comments and add
   some information, like their roles and number of comments on my site. It’s working
   okay with PHP < 8, but after updating to any version >= 8, it returns a strange
   result. Is there any known bug/incompatibility of wpdb with version 8 of php?
 * Example: inside my function, this is the result of $wpdb in PHP 7:
 *     ```wp-block-code
       wpdb Object
       (
       [show_errors] =>
       [suppress_errors] =>
       [last_error] =>
       [num_queries] => 145
       [num_rows] => 0
       [rows_affected] => 0
       [insert_id] => 0
       [last_query] => SELECT * FROM wp_users WHERE user_email = 'user@gmail.com' LIMIT 1
       [last_result] => Array
   
       etc...
       ```
   
 * So this way, I can get comment user’ ID and do my stuff, like this:
 *     ```wp-block-code
       $comm_count = $wpdb->get_var('SELECT COUNT (comment_ID) FROM ' . $wpdb->comments. ' WHERE comment_author_email = "' . get_comment_author_email() . '"');
       ```
   
 * But with PHP 8, this is happening:
 *     ```wp-block-code
       wpdb Object
       (
           [show_errors] => 
           [suppress_errors] => 
           [last_error] => 
           [num_queries] => 132
           [num_rows] => 0
           [rows_affected] => 0
           [insert_id] => 0
           [last_query] => SELECT * FROM wp_users WHERE user_login = '#' LIMIT 1
           [last_result] => Array
   
       etc...
       ```
   
 * The query goes from user_email to user_login, any clue why?

Viewing 1 replies (of 1 total)

 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [2 years ago](https://wordpress.org/support/topic/wpdb-bug-with-php-8/#post-17755060)
 * How do you call `$wpdb`? What does your function in which you generated this 
   debug output look like? And when is it executed?

Viewing 1 replies (of 1 total)

The topic ‘$wpdb bug with PHP > = 8?’ is closed to new replies.

## Tags

 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [threadi](https://wordpress.org/support/users/threadi/)
 * Last activity: [2 years ago](https://wordpress.org/support/topic/wpdb-bug-with-php-8/#post-17755060)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
