Title: php notice: SQL Syntax Error
Last modified: July 22, 2020

---

# php notice: SQL Syntax Error

 *  Resolved [dartrax](https://wordpress.org/support/users/dartrax/)
 * (@dartrax)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/)
 * Hi! I noticed getting this messages in php error log:
 * `[Wed Jul 22 19:45:14.350771 2020] [php7:notice] [pid 20096:tid 1864] [client::
   1:54745] WordPress database error You have an error in your SQL syntax; check
   the manual that corresponds to your MariaDB server version for the right syntax
   to use near 'WHERE hash = 'testuser1'' at line 1 for query SELECT * FROM WHERE
   hash = 'testuser1' made by wp_dashboard, do_meta_boxes, WC_Admin_Dashboard->recent_reviews,
   get_avatar, get_avatar_url, get_avatar_data, apply_filters('pre_get_avatar_data'),
   WP_Hook->apply_filters, Avatar_Privacy\\Components\\Avatar_Handling->get_avatar_data,
   Avatar_Privacy\\Components\\Avatar_Handling->should_show_gravatar, Avatar_Privacy\\
   Components\\Avatar_Handling->determine_gravatar_policy, Avatar_Privacy\\Core-
   >comment_author_allows_gravatar_use, Avatar_Privacy\\Core->load_data, Avatar_Privacy\\
   Core->load_data_by_hash, referer: http://localhost/wp_pub/produkt/testproduct/`
 * When I disable Avatar Privacy, they do not get generated any longer.
    I used 
   the “Identicon” avatar setting. The page with the avatars generating the errors
   is a woocommerce single product page with avatars at the reviews (comments).

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/topic/php-notice-sql-syntax-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/php-notice-sql-syntax-error/page/2/?output_format=md)

 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13157230)
 * Hi [@dartrax](https://wordpress.org/support/users/dartrax/)! That’s pretty weird.
   Is that the unmodified output? Do you really get “hash = ‘testuser1′”? I’m wondering
   how that’s possible (hash should be a SHA256 hex string). Could you please post
   more of the error log? There should be other errors before to arrive at such 
   a truncated SQL string.
 *  Thread Starter [dartrax](https://wordpress.org/support/users/dartrax/)
 * (@dartrax)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13157347)
 * Hi [@pputzer](https://wordpress.org/support/users/pputzer/), thank you for your
   reply! This is nearly unmodified. I only replaced a customer’s name with testuser1
   for privacy reasons. But it’s a clear username, not a hex string. This is one
   line in error.log. I post more of the error log, I only change the user names:
 *     ```
       [Wed Jul 22 20:07:31.778858 2020] [php7:notice] [pid 20096:tid 1772] [client ::1:55243] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE hash = 'Gerhard C.'' at line 1 for query SELECT * FROM  WHERE hash = 'Gerhard C.' made by wp_dashboard, do_meta_boxes, WC_Admin_Dashboard->recent_reviews, get_avatar, get_avatar_url, get_avatar_data, apply_filters('pre_get_avatar_data'), WP_Hook->apply_filters, Avatar_Privacy\\Components\\Avatar_Handling->get_avatar_data, Avatar_Privacy\\Components\\Avatar_Handling->should_show_gravatar, Avatar_Privacy\\Components\\Avatar_Handling->determine_gravatar_policy, Avatar_Privacy\\Core->comment_author_allows_gravatar_use, Avatar_Privacy\\Core->load_data, Avatar_Privacy\\Core->load_data_by_hash, referer: http://localhost/wp_pub/produkt/nanocul-433/
       [Wed Jul 22 20:07:31.780853 2020] [php7:notice] [pid 20096:tid 1772] [client ::1:55243] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE hash = 'Matthias B.'' at line 1 for query SELECT * FROM  WHERE hash = 'Matthias B.' made by wp_dashboard, do_meta_boxes, WC_Admin_Dashboard->recent_reviews, get_avatar, get_avatar_url, get_avatar_data, apply_filters('pre_get_avatar_data'), WP_Hook->apply_filters, Avatar_Privacy\\Components\\Avatar_Handling->get_avatar_data, Avatar_Privacy\\Components\\Avatar_Handling->should_show_gravatar, Avatar_Privacy\\Components\\Avatar_Handling->determine_gravatar_policy, Avatar_Privacy\\Core->comment_author_allows_gravatar_use, Avatar_Privacy\\Core->load_data, Avatar_Privacy\\Core->load_data_by_hash, referer: http://localhost/wp_pub/produkt/nanocul-433/
       [Wed Jul 22 20:07:31.782848 2020] [php7:notice] [pid 20096:tid 1772] [client ::1:55243] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE hash = 'maxmuster9586'' at line 1 for query SELECT * FROM  WHERE hash = 'maxmuster9586' made by wp_dashboard, do_meta_boxes, WC_Admin_Dashboard->recent_reviews, get_avatar, get_avatar_url, get_avatar_data, apply_filters('pre_get_avatar_data'), WP_Hook->apply_filters, Avatar_Privacy\\Components\\Avatar_Handling->get_avatar_data, Avatar_Privacy\\Components\\Avatar_Handling->should_show_gravatar, Avatar_Privacy\\Components\\Avatar_Handling->determine_gravatar_policy, Avatar_Privacy\\Core->comment_author_allows_gravatar_use, Avatar_Privacy\\Core->load_data, Avatar_Privacy\\Core->load_data_by_hash, referer: http://localhost/wp_pub/produkt/nanocul-433/
       [Wed Jul 22 20:07:31.783845 2020] [php7:notice] [pid 20096:tid 1772] [client ::1:55243] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE hash = 'testuser1'' at line 1 for query SELECT * FROM  WHERE hash = 'testuser1' made by wp_dashboard, do_meta_boxes, WC_Admin_Dashboard->recent_reviews, get_avatar, get_avatar_url, get_avatar_data, apply_filters('pre_get_avatar_data'), WP_Hook->apply_filters, Avatar_Privacy\\Components\\Avatar_Handling->get_avatar_data, Avatar_Privacy\\Components\\Avatar_Handling->should_show_gravatar, Avatar_Privacy\\Components\\Avatar_Handling->determine_gravatar_policy, Avatar_Privacy\\Core->comment_author_allows_gravatar_use, Avatar_Privacy\\Core->load_data, Avatar_Privacy\\Core->load_data_by_hash, referer: http://localhost/wp_pub/produkt/nanocul-433/
       ```
   
 * I think the code is called in woocommerce single-product-reviews.php with those
   lines:
 *     ```
       <ol class="commentlist">
       	<?php wp_list_comments( apply_filters( 'woocommerce_product_review_list_args', array( 'callback' => 'woocommerce_comments' ) ) ); ?>
       </ol>
       ```
   
 * Please tell me what else do you need to find out what causes this?
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13162653)
 * [@dartrax](https://wordpress.org/support/users/dartrax/) Is it possible that 
   these comments do not have an email address set and that woocommerce has set 
   that field to the username instead? Still, there should be a table name in the
   query unless something goes wrong very early. Can you reproduce the issue in 
   a minimal system?
 *  Thread Starter [dartrax](https://wordpress.org/support/users/dartrax/)
 * (@dartrax)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13162814)
 * Hi [@pputzer](https://wordpress.org/support/users/pputzer/),
    if I look at the
   database table comments, where comment_type is review, comment_author_email contains
   the mail adresses and comment_author the usernames. I don’t know if this is important:
   user_id is equal for all of them, because I created the review-comments manually(
   via wordpress) and changed the comment_author_email and comment_author after 
   creation (via wordpress). The reason for that is that the customers do not have
   their own account (guestorder) and I got their reviews by mail.
 * Do you need some more database insight?
 * If this alone doesn’t help, I will try it tomorrow with unmodified comments by
   testuser accounts. If that makes a difference, I should be able to explain how
   to reproduce.
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13167127)
 * Are you saying that the have a non-zero but invalid user ID attached? That could
   be part of the problem (anonymous comments normally have 0 as the user ID). Still
   it’s kind of hard to image having everything fail in exactly this way.
 * It would be best if you could try to recreate the issue in a minimal environment(
   default theme, as few plugins as possible).
 *  Thread Starter [dartrax](https://wordpress.org/support/users/dartrax/)
 * (@dartrax)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13167224)
 * No, user ID is 1, that is admin ID. Admin created those comments and changed 
   the comment_author_email and comment_author after creation (via wordpress).
 * I’ll try that, I hope to find the time for that on Sunday.
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13171709)
 * Any luck?
 *  Thread Starter [dartrax](https://wordpress.org/support/users/dartrax/)
 * (@dartrax)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13172140)
 * No. I could not reproduce it on another wordpress instance yet. I tried to track
   it down on the one where the notice appeared by disabling all plugins and enabling
   one by one. Once I had only woocommerce and Antispam Bee enabled I saw the notice.
   I wanted to be sure and disabled Antispam Bee again. Since that I was not able
   to reproduce that any longer, even with Antispam Bee and all other plugins enabled.
   I don’t know if there is some kind of caching getting in the way now. I’ll have
   to observe that…
 * Edit: Half an hour later, it’s there again…
    -  This reply was modified 5 years, 8 months ago by [dartrax](https://wordpress.org/support/users/dartrax/).
 *  Thread Starter [dartrax](https://wordpress.org/support/users/dartrax/)
 * (@dartrax)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13189102)
 * I think I have tracked it down to this two extensions that, if enabled together,
   lead to the descripted behavior:
    - Avatar Privacy
    - SSO for Flarum
 * I’ll report this to the developer of SSO for Flarum as well. That plugin is in
   active development and I’m already in contact with him.
 * It would be great if there is a way to display the avatars generated by Avatar
   Privacy in the Flarum Forum as well, but this should be discussed in another 
   thread.
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13196505)
 * I’ll look into it if you give me a link to the other plugin. I’m very interested
   what could possibly interfere like this.
 *  Thread Starter [dartrax](https://wordpress.org/support/users/dartrax/)
 * (@dartrax)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13196687)
 * Of course!
 * Plugin:
    [https://wordpress.org/plugins/sso-flarum/](https://wordpress.org/plugins/sso-flarum/)
 * Documentation:
    [https://docs.maicol07.it/docs/en/flarum_sso/introduction](https://docs.maicol07.it/docs/en/flarum_sso/introduction)
 * Source repo:
    [https://github.com/maicol07/flarum_sso_wp_plugin/releases](https://github.com/maicol07/flarum_sso_wp_plugin/releases)
 * Community:
    [https://discuss.flarum.org/d/21666-php-and-wordpress-single-sign-on-sso](https://discuss.flarum.org/d/21666-php-and-wordpress-single-sign-on-sso)
 * Bugtracker:
    [https://bugs.maicol07.it/dashboard?id=2892ed24-87fb-4413-8ccf-905fba665b21](https://bugs.maicol07.it/dashboard?id=2892ed24-87fb-4413-8ccf-905fba665b21)
 *  Thread Starter [dartrax](https://wordpress.org/support/users/dartrax/)
 * (@dartrax)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13207472)
 * The Author of SSO for Flarum responded, he thinks the bug is in Avatar Privacy
   code.
    [https://bugs.maicol07.it/issue/FSSOE-14#focus=Comments-4-3.0-0](https://bugs.maicol07.it/issue/FSSOE-14#focus=Comments-4-3.0-0)
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13209738)
 * Unfortunately, this looks like an _a priori_ dismissal to me (at least he didn’t
   include any reasoning why he thinks that, so it does not help me narrow things
   down).
 *  Thread Starter [dartrax](https://wordpress.org/support/users/dartrax/)
 * (@dartrax)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13216908)
 * I asked for a more detailed guess and got this:
 * > Well, I don’t use that query in my plugin. I’ll test it in my local environment.
   > I can’t replicate the error.
   >  I’ve noticed now that the error trace shows where
   > the exception occured: none of that functions are used by the Flarum SSO WP
   > Plugin
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/#post-13335753)
 * [@dartrax](https://wordpress.org/support/users/dartrax/) Sorry for the delay.
   I’ve tried to reproduce this issue with the two plugins installed, but could 
   not. Can you please try to reproduce this in a minimal environment (fresh WP 
   installation, default theme, just the two plugins)? If you cannot reproduce it
   in this environment, try to add things one by one until you get the effect described.
 * I’ve managed to reproduce the issue after all. SSL-Flarum has got nothing to 
   do with it, it’s something weird with WooCommerce reviews. I’ll investigate.
    -  This reply was modified 5 years, 7 months ago by [pepe](https://wordpress.org/support/users/pputzer/).

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/topic/php-notice-sql-syntax-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/php-notice-sql-syntax-error/page/2/?output_format=md)

The topic ‘php notice: SQL Syntax Error’ is closed to new replies.

 * ![](https://ps.w.org/avatar-privacy/assets/icon.svg?rev=2711226)
 * [Avatar Privacy](https://wordpress.org/plugins/avatar-privacy/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/avatar-privacy/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/avatar-privacy/)
 * [Active Topics](https://wordpress.org/support/plugin/avatar-privacy/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/avatar-privacy/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/avatar-privacy/reviews/)

## Tags

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

 * 26 replies
 * 2 participants
 * Last reply from: [pepe](https://wordpress.org/support/users/pputzer/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/php-notice-sql-syntax-error/page/2/#post-13858335)
 * Status: resolved