I encountered a SQL syntax error in CoAuthorsPlus plugin when running a WP-CLI command wp co-authors-plus assign-user-to-coauthor
. The error message is as follows:
[11-Jul-2024 04:19:32 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 '','page)' at line 1 for query SELECT ID FROM wp_posts WHERE post_author=270 AND post_type IN (post','page) made by...
The problem lies in the SQL query construction in co-authors-plus/php/class-wp-cli.php
at line 238. The code currently is:
$post_types = implode( "','", $coauthors_plus->supported_post_types() );
$posts = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author=%d AND post_type IN ({$post_types})", $user->ID ) );
This results in an SQL syntax error because the post_type values are not properly enclosed in single quotes in the IN clause.
Proposed Fix:
// add single quotes
$posts = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author=%d AND post_type IN ('{$post_types}')", $user->ID ) );
I hope this issue can be resolved quickly.
Thank you!
]]>I’m getting recently this error, after using Database Optimizer ?
[28-Jan-2023 16:10:18 UTC] 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 ‘LEFT JOIN
wp_posts
ONwp_posts
.ID =wp_postmeta
.post_id
WHERE…’ at line 3 for query DELETE FROMwp_postmeta
LEFT JOINwp_posts
ONwp_posts
.ID =wp_postmeta
.post_id
WHEREwp_posts
.post_type = ‘revision’ made by require_once(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’), do_action(‘init’), WP_Hook->do_action, WP_Hook->apply_filters, LiteSpeed\Core->after_user_init, LiteSpeed\Core->proceed_action, LiteSpeed\Router->handler, LiteSpeed\DB_Optm->handler, LiteSpeed\DB_Optm->_db_clean
what seems to be the problem, could you help me with this, please
regards
]]>[02-Dec-2021 06:09:18 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 '' at line 6 for query SELECT postmeta.post_id AS product_id
FROM wp_postmeta AS postmeta
LEFT JOIN wp_posts AS products ON ( products.ID = postmeta.post_id )
WHERE postmeta.meta_key LIKE 'attribute_%'
AND postmeta.meta_value = 'XL'
AND products.post_parent = made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), do_action('template_redirect'), WP_Hook->do_action, WP_Hook->apply_filters, WC_AJAX::do_wc_ajax, do_action('wc_ajax_xoo_wsc_add_to_cart'), WP_Hook->do_action, WP_Hook->apply_filters, xoo_wsc_Cart_Data->xoo_wsc_add_to_cart_ajax, WC_AJAX::get_refreshed_fragments, woocommerce_mini_cart, wc_get_template, include('/plugins/woocommerce/templates/cart/mini-cart.php'), wc_get_formatted_cart_item_data, apply_filters('woocommerce_variation_option_name'), WP_Hook->apply_filters, display_price_in_variation_option_name
]]>Company recently bought this plugin, and all is fine, but one thing. This error popped up:
[STDERR] WordPress errore sul database 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 ') LEFT JOIN wpnq_cjtoolbox_plus_block_pintype pt ON blocks.
id= pt.
bloc…’ at line 1 per la query SELECT blocks.id,blocks.owner,blocks.name,blocks.pinPoint,blocks.location,blocks.links,blocks.expressions,0 as blocksGroup FROM wpnq_cjtoolbox_blocks blocks LEFT JOIN wpnq_cjtoolbox_block_pins pins0 ON blocks.id = pins0.blockId AND pins0.pin=’categories’ AND pins0.value IN( ) LEFT JOIN wpnq_cjtoolbox_plus_block_pintype pt ON blocks.id
= pt.blockId
WHERE ( ( ( backupId IS NULL ) AND ( state = “active” ) ) AND ( ( pt.pinName = ‘category’ AND pt.invert = 1 ) ) AND ( ( ( pins0.pin IS NULL ) AND ( pins0.value IS NULL ) ) ) ); fatta da require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’), WP_Hook->do_action, WP_Hook->apply_filters, CJTBlocksCouplingController->initCoupling, CJTBlocksCouplingController->getBlocks, CJTCouplingModel->getPinsBlocks, apply_filters(‘cjt-blocks-coupling-model-blocks-queue’), WP_Hook->apply_filters, CJTPlusHooksCJTBlockAssignmentNegative->_blocksQueue`
Any help would be appreciated.
]]>I followed the advice on this post:
https://www.ads-software.com/support/topic/need-help-deleting-tens-of-thousands-of-posts/
I used this to delete the meta data and it worked:
DELETE FROM wp_postmeta WHERE post_id in (SELECT ID FROM wp_posts WHERE ID BETWEEN 10866 AND 38059);
But I’m having an issue with the removing the posts.
I used the code in that thread:
DELETE FROM wp_posts where ID GE 10866 AND ID LE 38059;
It brings up an error:
#1064 – 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 ‘GE 10866 AND ID LE 38059’ at line 1
I can’t seem to figure out the correct syntax to make it work.
Can someone please let me know the correct syntax?
Much thanks in advance!
]]>this error log is showing following error:
“[23-Jul-2020 03:31:36 UTC] 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 ‘)’ at line 3 for query SELECT option_name AS id, option_value AS value
FROM wp_options
WHERE option_name IN ( ) made by wp_xmlrpc_server->serve_request, IXR_Server->IXR_Server, IXR_Server->__construct, IXR_Server->serve, IXR_Server->call, IXR_Server->multiCall, IXR_Server->call, Jetpack_XMLRPC_Server->json_api, WPCOM_JSON_API->serve, WPCOM_JSON_API->process_request, Jetpack_JSON_API_Endpoint->callback, Jetpack_JSON_API_Sync_Close_Endpoint->result, Automattic\Jetpack\Sync\Queue->peek_by_id, Automattic\Jetpack\Sync\Queue->fetch_items_by_id”
Please help
]]>Cron error:
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 '' at line 7
SELECT order_id, order_date, request_items FROM jdf4sk_ywrr_email_schedule
WHERE mail_status = 'pending' AND scheduled_date <= '2019-03-05 21:00:03'
ORDER BY id DESC
LIMIT
Realized by do_action_ref_array, WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, YWRR_Schedule->hourly_schedule
Array
(
)
]]>[13-Oct-2017 06:08:33 UTC] WordPress database error Duplicate key name ‘datetime’ for query ALTER TABLE wp_iqblock_logging ADD KEY datetime
(datetime
) made by require(‘wp-blog-header.php’), require_once(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’), include_once(‘/plugins/iq-block-country/iq-block-country.php’), iqblockcountry_upgrade, iqblockcountry_install_db, dbDelta
like every second on my site.
]]>You are welcome to leave your feedbacks and report issues connected to the WPTables plugin. Any ideas and possible improvements are highly appreciated!
Regards,
Ian
I have used UpdraftPlus before with no issue, however I’ve recently had to wipe my laptop and wanted to put copies of the websites I’m working on on my computer to use with localhost/wampserver. All was fine with the transfer except when uploading the database into phpmyadmin. Here is an error I received for one website:
#1064 – 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 ‘evl_options-transients’, ‘a:3:{s:14:”changed_values”;a:1:{s:15:”evl_css_content”‘ at line 103
This particular website is running on a child theme of the Evolve theme.
I’ll also add that I then downloaded the database via my cpanel, made the necessary url and database name changes and uploaded it locally with no hassle. So, I wonder what the above error refers to and why it only happened with UpdraftPlus?
Thanks
https://www.ads-software.com/plugins/updraftplus/
]]>