WordPress插件数据库错误您的SQL语法有错误

时间:2018-07-07 22:03:56

标签: php mysql database wordpress

每次加载页面时,我都会多次收到此消息。 [07-Jul-2018 17:30:49 UTC] WordPress数据库错误您的SQL语法错误;检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第6行的'AND p.post_status ='publish'附近使用查询SELECT count(*)FROM wp_posts p

    [07-Jul-2018 17:30:49 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_status='publish'' at line 6 for query SELECT count(*) FROM wp_posts p
INNER JOIN wp_term_relationships tr ON tr.object_id = p.ID
INNER JOIN wp_term_taxonomy tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
INNER JOIN wp_geo_mashup_location_relationships gmlr ON gmlr.object_id = p.ID AND gmlr.object_name = 'post'
WHERE tt.term_id =
AND p.post_status='publish' made by require('wp-blog-header.php'),
require_once('wp-includes/template-loader.php'),
include('/themes/hestia-child/front-page.php'),
get_footer, locate_template, load_template,
require_once('/themes/hestia-child/footer.php'),
do_action('hestia_do_footer_child'),
WP_Hook->do_action, WP_Hook->apply_filters,
call_user_func_array, hestia_the_footer_content_child,
dynamic_sidebar, call_user_func_array, WP_Widget->display_callback,
WP_Widget_Categories->widget, wp_dropdown_categories,
walk_category_dropdown_tree, call_user_func_array, Walker->walk, Walker->display_element,
call_user_func_array, Walker_CategoryDropdown->start_el, apply_filters('list_cats'),
WP_Hook->apply_filters, call_user_func_array, GeoMashup::list_cats, GeoMashupDB::category_located_post_count

我认为它导致了GeoMashup的“ geo-mashup-db.php”部分(在下面复制),并且我读了一些有关ID / id之间大小写不匹配的问题,但是我可以似乎找不到任何实例。任何帮助或建议将是巨大的。

* Get the number of located posts in a category.
*
* @since 1.2
*
* @param id $category_id
* @return int
*/
public static function category_located_post_count( $category_id ) {
global $wpdb;

$select_string = "SELECT count(*) FROM {$wpdb->posts} p
INNER JOIN {$wpdb->term_relationships} tr ON tr.object_id = p.ID
INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
INNER JOIN {$wpdb->prefix}geo_mashup_location_relationships gmlr ON gmlr.object_id = p.ID AND gmlr.object_name = 'post'
WHERE tt.term_id = " . esc_sql( $category_id ) ."
AND p.post_status='publish'";
return $wpdb->get_var( $select_string );
}

/**
* Get categories that contain located objects.
*
* Not sufficient - probably want parent categories.
*
* @return array Located category id, name, slug, description, and parent id
*/
private static function get_located_categories() {
global $wpdb;

$select_string = "SELECT DISTINCT t.term_id, t.name, t.slug, tt.description, tt.parent
FROM {$wpdb->prefix}geo_mashup_location_relationships gmlr
INNER JOIN {$wpdb->term_relationships} tr ON tr.object_id = gmlr.object_id
INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
INNER JOIN {$wpdb->terms} t ON t.term_id = tt.term_id
WHERE tt.taxonomy='category'
ORDER BY t.slug ASC";
return $wpdb->get_results( $select_string );
}

1 个答案:

答案 0 :(得分:0)

一篇较旧的文章,但值得一提:问题在于Geo Mashup的小部件选项,该选项可“自动”创建类别的地图链接(管理员>“模糊设置”)。

所有类别中的所有帖子都必须保存所有GeoMetala t,lnggeo-address和已保存的名称),否则您会经常收到此错误。

取消选中Add map links to category lists将停止错误。
按名称/ ID映射类别的简码和模板标签仍然可以正常工作。

希望这可以帮助某人。