Title: Bug fix for WordPress database error
Last modified: April 8, 2021

---

# Bug fix for WordPress database error

 *  Resolved [oldwebgeek](https://wordpress.org/support/users/oldwebgeek/)
 * (@oldwebgeek)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/bug-fix-for-wordpress-database-error/)
 * Errors surfacing in our PHP logs:
 * WordPress database error You have an error in your SQL syntax; check the manual
   that corresponds to your MySQL server version for the right syntax to use near‘
   WHERE 1 = 1 AND session_id=’k16jd8b356094f670bs1hog400” at line 1 for query SELECT*
   FROM WHERE 1 = 1 AND session_id=’k16jd8b356094f670bs1hog400’ made by Pantheon_Sessions\
   Session_Handler->write, Pantheon_Sessions\Session::get_by_sid
 * This plugin is running off a multi-node XtraDB cluster (Galera), mysql v5.7. 
   Engine InnoDB.
 * Here’s the fix that resolved the issue.
 * In inc/class-session.php, line ~65, (above or below) add:
 * `$table_name = $wpdb->pantheon_sessions;`
 * Then change this at line ~68 from:
 * `$session_row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->pantheon_sessions}
   WHERE {$column_name}=%s", $sid ) );`
 * To:
 * `$session_row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$table_name} 
   WHERE {$column_name}=%s", $sid ) );`

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Contributor [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * (@danielbachhuber)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/bug-fix-for-wordpress-database-error/#post-14298106)
 * Thanks for the report, [@oldwebgeek](https://wordpress.org/support/users/oldwebgeek/)!
 * I wouldn’t have expected that to be an issue, but I’m glad to hear you tracked
   down a fix. I [applied the change](https://github.com/pantheon-systems/wp-native-php-sessions/pull/188)
   to WP Native PHP Sessions v1.2.3 so you can continue to safely update the plugin.
 *  Thread Starter [oldwebgeek](https://wordpress.org/support/users/oldwebgeek/)
 * (@oldwebgeek)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/bug-fix-for-wordpress-database-error/#post-14298954)
 * Thanks Daniel. That may not have actually fixed the issue because I noticed more
   of the same log events after I patched my local copy of the plugin the day I 
   posted the initial report. However, I’ve run the plugin update from the WP dashboard
   and will let you know if I see more of those errors.
 * One other item, I also noticed were these errors in our logs, issues are probably
   related:
 * 2021-04-09T15:15:21.000Z – – [09-Apr-2021 11:15:21 America/New_York] WordPress
   database error Incorrect table name ” for query SHOW FULL COLUMNS FROM  made 
   by Pantheon_Sessions\Session_Handler->write, Pantheon_Sessions\Session::create_for_sid
 *  Thread Starter [oldwebgeek](https://wordpress.org/support/users/oldwebgeek/)
 * (@oldwebgeek)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/bug-fix-for-wordpress-database-error/#post-14299569)
 * Looks like this is still an issue. At first, I thought is was a string interpolation
   issue, but somehow $wpdb->pantheon_sessions is empty.
 * `2021-04-09T17:49:42.000Z - - [09-Apr-2021 13:49:42 America/New_York] WordPress
   database error You have an error in your SQL syntax; check the manual that corresponds
   to your MySQL server version for the right syntax to use near 'WHERE session_id
   ='b9npncnar5sk687c1oa62jbbt0'' at line 1 for query SELECT * FROM WHERE session_id
   ='b9npncnar5sk687c1oa62jbbt0' made by Pantheon_Sessions\Session_Handler->write,
   Pantheon_Sessions\Session::create_for_sid, Pantheon_Sessions\Session::get_by_sid`
 *  Plugin Contributor [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * (@danielbachhuber)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/bug-fix-for-wordpress-database-error/#post-14309202)
 * [@oldwebgeek](https://wordpress.org/support/users/oldwebgeek/) Darn! Any luck
   tracking it down further? Are you using something like HyperDB or LudicrousDB?
 *  Thread Starter [oldwebgeek](https://wordpress.org/support/users/oldwebgeek/)
 * (@oldwebgeek)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/bug-fix-for-wordpress-database-error/#post-14309995)
 * No. Still seeing the errors. Doesn’t seem to prevent the plugin from working.
 * It’s weird, we’re using Percona XtraDB cluster (Galera).
    -  This reply was modified 5 years, 1 month ago by [oldwebgeek](https://wordpress.org/support/users/oldwebgeek/).
 *  [batman36](https://wordpress.org/support/users/batman36/)
 * (@batman36)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/bug-fix-for-wordpress-database-error/#post-14775937)
 * I have a similar situation:
 * [17-Aug-2021 11:30:34 UTC] WordPress database error Table ‘hmprintd_esign.wp_pantheon_sessions’
   doesn’t exist for query SELECT * FROM wp_pantheon_sessions WHERE secure_session_id
   =’1f1df06d2ba954ab7f4b268065b32cc9′ made by shutdown_action_hook, do_action(‘
   shutdown’), WP_Hook->do_action, WP_Hook->apply_filters, session_write_close, 
   Pantheon_Sessions\Session_Handler->write, Pantheon_Sessions\Session::create_for_sid,
   Pantheon_Sessions\Session::get_by_sid
 * hundreds of rows of this

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Bug fix for WordPress database error’ is closed to new replies.

 * ![](https://ps.w.org/wp-native-php-sessions/assets/icon-256x256.png?rev=3411177)
 * [Native PHP Sessions](https://wordpress.org/plugins/wp-native-php-sessions/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-native-php-sessions/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-native-php-sessions/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-native-php-sessions/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-native-php-sessions/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-native-php-sessions/reviews/)

## Tags

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

 * 6 replies
 * 3 participants
 * Last reply from: [batman36](https://wordpress.org/support/users/batman36/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/bug-fix-for-wordpress-database-error/#post-14775937)
 * Status: resolved