Title: SQL syntax error in log
Last modified: May 11, 2022

---

# SQL syntax error in log

 *  Resolved [Preliot](https://wordpress.org/support/users/preliot/)
 * (@preliot)
 * [4 years ago](https://wordpress.org/support/topic/sql-syntax-error-in-log/)
 * I’m seeing these sql errors in my log file. Because it was unreadable, i’ve added
   whitespaces. Also replace my theme name with <theme>.
 * [28-Apr-2022 23:39:44 UTC] WordPress databasefout 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
 * `'))) AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish'...'`
 * at line 3 bij query
 *     ```
       SELECT wp_posts.* 
       FROM wp_posts  
       LEFT JOIN wp_icl_translations wpml_translations
       ON wp_posts.ID = wpml_translations.element_id
       AND wpml_translations.element_type = CONCAT('post_', wp_posts.post_type)  WHERE 1=1  
       AND ((()))  
       ```
   
 *     ```
       AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) 
       OR (wp_posts.post_type = 'page' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) 
       OR (wp_posts.post_type = 'attachment' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) 
       OR (wp_posts.post_type = 'product' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) 
       OR (wp_posts.post_type = 'aiovg_videos' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) 
       OR (wp_posts.post_type = 'news' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) 
       OR (wp_posts.post_type = 'custom_type' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled'))) 
       ```
   
 *     ```
       AND (((wpml_translations.language_code = 'nl' OR 0 ) 
       AND wp_posts.post_type  IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','acf-field-group','product','product_variation','aiovg_videos','news' ))
       OR wp_posts.post_type  NOT  IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','acf-field-group','product','product_variation','aiovg_videos','news' ))
   
       ORDER BY wp_posts.post_date DESC  
       ```
   
 *     ```
       gemaakt door 
       require('wp-blog-header.php'), 
       require_once('wp-includes/template-loader.php'), 
       include('/themes/<theme>/search.php'), 
       get_footer, 
       locate_template, 
       load_template, 
       require_once('/themes/<theme>/footer-without-newsletter.php'), 
       get_template_part, 
       locate_template, 
       load_template, 
       require('/themes/<theme>/partials/footer/footer-end.php'), 
       wp_footer, 
       do_action('wp_footer'), 
       WP_Hook->do_action, 
       WP_Hook->apply_filters, 
       WpMatomo\TrackingCode->add_javascript_code, 
       WpMatomo\TrackingCode\TrackingCodeGenerator->get_tracking_code, 
       WpMatomo\TrackingCode\TrackingCodeGenerator->apply_search_changes, 
       WP_Query->__construct, 
       WP_Query->query, 
       WP_Query->get_posts
       ```
   
    -  This topic was modified 4 years ago by [Preliot](https://wordpress.org/support/users/preliot/).
    -  This topic was modified 4 years ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).

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

 *  [mattmary](https://wordpress.org/support/users/mattmary/)
 * (@mattmary)
 * [4 years ago](https://wordpress.org/support/topic/sql-syntax-error-in-log/#post-15626579)
 * Hi [@preliot](https://wordpress.org/support/users/preliot/)
 * I’m sorry but your problem doesn’t look like related to the matomo plugin.
 * Kind regards
 * Mat
 *  Thread Starter [Preliot](https://wordpress.org/support/users/preliot/)
 * (@preliot)
 * [4 years ago](https://wordpress.org/support/topic/sql-syntax-error-in-log/#post-15627084)
 * Hello Mat,
 * The stacktrace starts in my footer with the wp footer hook which triggers add_javascript_code,
   which in turns starts this issue.
 * But where should ik look? ACF? MariaDB? something else?
    -  This reply was modified 4 years ago by [Preliot](https://wordpress.org/support/users/preliot/).
 *  [mattmary](https://wordpress.org/support/users/mattmary/)
 * (@mattmary)
 * [4 years ago](https://wordpress.org/support/topic/sql-syntax-error-in-log/#post-15629877)
 * hi [@preliot](https://wordpress.org/support/users/preliot/)
 * can you share the callstack of this error?
 * Kind regards
 * Mat
 *  Thread Starter [Preliot](https://wordpress.org/support/users/preliot/)
 * (@preliot)
 * [4 years ago](https://wordpress.org/support/topic/sql-syntax-error-in-log/#post-15634106)
 * Hello [@mattmary](https://wordpress.org/support/users/mattmary/),
 * Unfortunatly there’s no stacktrace, but this is the complete log message:
 *     ```
       [07-May-2022 10:29:10 UTC] WordPress databasefout 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 ')))  AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' ...' at line 3 bij query SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  LEFT  JOIN wp_icl_translations wpml_translations
       							ON wp_posts.ID = wpml_translations.element_id
       								AND wpml_translations.element_type = CONCAT('post_', wp_posts.post_type)  WHERE 1=1  AND ((()))  AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'page' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'attachment' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'product' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'aiovg_videos' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'news' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'custom_type' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled'))) AND ( ( ( wpml_translations.language_code = 'nl' OR 0 ) AND wp_posts.post_type  IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','acf-field-group','product','product_variation','aiovg_videos','news' )  ) OR wp_posts.post_type  NOT  IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','acf-field-group','product','product_variation','aiovg_videos','news' )  )  ORDER BY wp_posts.post_date DESC LIMIT 0, 10 gemaakt door require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts
       [07-May-2022 10:29:10 UTC] WordPress databasefout 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 ')))  AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' ...' at line 3 bij query SELECT   wp_posts.* FROM wp_posts  LEFT  JOIN wp_icl_translations wpml_translations
       							ON wp_posts.ID = wpml_translations.element_id
       								AND wpml_translations.element_type = CONCAT('post_', wp_posts.post_type)  WHERE 1=1  AND ((()))  AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'page' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'attachment' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'product' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'aiovg_videos' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'news' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')) OR (wp_posts.post_type = 'custom_type' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled'))) AND ( ( ( wpml_translations.language_code = 'nl' OR 0 ) AND wp_posts.post_type  IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','acf-field-group','product','product_variation','aiovg_videos','news' )  ) OR wp_posts.post_type  NOT  IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','acf-field-group','product','product_variation','aiovg_videos','news' )  )  ORDER BY wp_posts.post_date DESC  gemaakt door require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/<theme>/search.php'), get_footer, locate_template, load_template, require_once('/themes/<theme>/footer-without-newsletter.php'), get_template_part, locate_template, load_template, require('/themes/<theme>/partials/footer/footer-end.php'), wp_footer, do_action('wp_footer'), WP_Hook->do_action, WP_Hook->apply_filters, WpMatomo\TrackingCode->add_javascript_code, WpMatomo\TrackingCode\TrackingCodeGenerator->get_tracking_code, WpMatomo\TrackingCode\TrackingCodeGenerator->apply_search_changes, WP_Query->__construct, WP_Query->query, WP_Query->get_posts
       ```
   
    -  This reply was modified 4 years ago by [Preliot](https://wordpress.org/support/users/preliot/).
    -  This reply was modified 4 years ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
 *  Thread Starter [Preliot](https://wordpress.org/support/users/preliot/)
 * (@preliot)
 * [4 years ago](https://wordpress.org/support/topic/sql-syntax-error-in-log/#post-15634113)
 * Last part tells the story where the call orginates (see topic start for better
   view).
    Any insight would be appreciated.
 *  [mattmary](https://wordpress.org/support/users/mattmary/)
 * (@mattmary)
 * [4 years ago](https://wordpress.org/support/topic/sql-syntax-error-in-log/#post-15637152)
 * Hi [@preliot](https://wordpress.org/support/users/preliot/)
 * this is the get_search_query method which generates this bad sql request.
    You
   should look in your source code to the applied filters get_search_query: one 
   of them generates this wrong part in your sql request.
 *  Thread Starter [Preliot](https://wordpress.org/support/users/preliot/)
 * (@preliot)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/sql-syntax-error-in-log/#post-15697837)
 * [@mattmary](https://wordpress.org/support/users/mattmary/) Thanks for your efforts.
   With your suggestion i’ve traced the issue elsewhere (WooCommerce) and posted
   the issue here: [WooCommerce sql syntax error](https://wordpress.org/support/topic/sql-syntax-error-in-log-2).

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

The topic ‘SQL syntax error in log’ is closed to new replies.

 * ![](https://ps.w.org/matomo/assets/icon-256x256.png?rev=3531741)
 * [Matomo Analytics - Powerful, Privacy-First Insights for WordPress](https://wordpress.org/plugins/matomo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/matomo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/matomo/)
 * [Active Topics](https://wordpress.org/support/plugin/matomo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/matomo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/matomo/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Preliot](https://wordpress.org/support/users/preliot/)
 * Last activity: [3 years, 12 months ago](https://wordpress.org/support/topic/sql-syntax-error-in-log/#post-15697837)
 * Status: resolved