gpt4 book ai didi

mysql - WordPress MYSQL 错误

转载 作者:行者123 更新时间:2023-11-30 22:24:09 25 4
gpt4 key购买 nike

有人可以帮我解决下面的错误吗?

错误

[Fri Mar 04 23:37:59.682275 2016] [:error] [pid 9392] [client 222.127.94.8:45468] 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 10 for query SELECT DISTINCT ID, post_title, post_password, comment_ID,\n comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved,\n comment_type,comment_author_url,\n SUBSTRING(comment_content,1,110) AS com_excerpt\n FROM wp_comments\n LEFT OUTER JOIN wp_posts ON (wp_comments.comment_post_ID =\n wp_posts.ID)\n WHERE comment_approved = '1' AND comment_type = '' AND\n post_password = ''\n ORDER BY comment_date_gmt DESC LIMIT made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/theme/404.php'), dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, Comments->widget, referer:

主题中的代码:

$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved,
comment_type,comment_author_url,
SUBSTRING(comment_content,1,100) AS com_excerpt
FROM $wpdb->comments
LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
$wpdb->posts.ID)
WHERE comment_approved = '1' AND comment_type = '' AND
post_password = ''
ORDER BY comment_date_gmt DESC LIMIT ".$comment_posts;

$comments = $wpdb->get_results($sql);
$output = $pre_HTML;

foreach ($comments as $comment) {

我需要在上面的代码中替换什么来修复错误?

提前致谢

最佳答案

我在 wordpress 查询中使用 order by 和 limit 时遇到了类似的问题。我重写了 here 中所示的查询。 .我认为 wordpress 在附加变量时有不同的结构。试试吧。

关于mysql - WordPress MYSQL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35803244/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com