[Resolved] SQL Syntax Error in PHP Logs — Assistance Needed for Diagnosis
This thread is resolved. Here is a description of the problem and solution.
Problem: You are experiencing SQL syntax errors in the PHP logs on your WordPress site using BeTheme and WPML. The errors persist despite checking compatibility and updating plugins and themes. Solution: We recommend updating your MySQL server to version 8.0 or higher, if you are currently using MySQL 5.7.xx, which is outdated. This update could resolve the SQL syntax errors you are encountering.
If this solution does not apply to your case, or if it is outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If issues persist, please open a new support ticket at WPML support forum for further assistance.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Background of the issue:
I am experiencing an issue on my WordPress site related to errors appearing in the PHP logs. The error messages are related to SQL syntax errors. I have checked compatibility of PHP and MySQL versions with current plugins and theme, updated all plugins and theme to the latest versions, and disabled plugins one by one to identify the source, but the error persists. I am using BeTheme and WPML. Here is a link to a page where the issue can be seen: hidden link. SQL error: [15-Nov-2024 08:25:26 UTC] 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 'AND p.post_type='attachment' AND p.post_status = 'inherit' ) ) ' at line 18 for query SELECT p.ID FROM GwB_posts AS p JOIN GwB_icl_translations wpml_translations ON wpml_translations.element_id = p.ID AND wpml_translations.element_type = 'post_portfolio' WHERE p.post_date > '2024-03-16 16:50:30' AND p.post_type = 'portfolio' AND p.post_status = 'publish' AND (language_code = 'en' OR ( wpml_translations.language_code = 'en' AND p.post_type IN ( 'portfolio' ) AND ( ( ( SELECT COUNT(element_id) FROM GwB_icl_translations WHERE trid = wpml_translations.trid AND language_code = 'en' ) = 0 ) OR ( ( SELECT COUNT(element_id) FROM GwB_icl_translations t2 JOIN GwB_posts p ON p.id = t2.element_id WHERE t2.trid = wpml_translations.trid AND t2.language_code = 'en' AND ( p.post_status = 'publish' OR p.post_status = 'private' OR AND p.post_type='attachment' AND p.post_status = 'inherit' ) ) ) = 0 ) ) ) ) ORDER BY p.post_date ASC LIMIT 1 made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/betheme/single-portfolio.php'), get_template_part, locate_template, load_template, require('/themes/betheme/includes/content-single-portfolio.php'), get_adjacent_post.
Symptoms:
SQL syntax error in PHP logs occurring sometimes every second, sometimes every hour. No other errors are present in the error_log file.
Questions:
Help identify which component (plugin, theme, or translation tool) is causing this error.
Provide recommendations for fixing the SQL syntax or configuration that may resolve the issue.