2016-03-04 71 views
1

有人可以帮我修复下面的错误吗?Wordpress MYSQL错误

错误

[周五23年3月4日:37:59.682275 2016年] [:错误] [PID 9392] [客户 222.127.94.8:45468] WordPress数据库错误你有一个错误的SQL语法;检查对应于您MariaDB的服务器 版本在10号线附近使用'查询 SELECT DISTINCT ID,POST_TITLE,post_password,COMMENT_ID,\ n comment_post_ID,COM​​MENT_AUTHOR,comment_author_email, comment_date_gmt,comment_approved正确的语法手册, \ n comment_type,comment_author_url,\ n SUBSTRING(COMMENT_CONTENT,1110)AS com_excerpt \ n的wp_comments \ n LEFT OUTER JOIN wp_posts ON (wp_comments.comment_post_ID = \ n wp_posts.ID)\ n其中comment_approved = '1' AND comment_type =''AND \ n post_password =''\ n ORDER BY comment_date_gmt DESC LIMIT由require('wp-blog-header.php')制作, require_once('wp-includes/template-loader.php'), include('/ themes/them E/404.php“),dynamic_sidebar, call_user_func_array,WP_Widget-> display_callback,评论 - >部件, 引用者:

守则主题:

$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) { 

我需要做什么来取代上面的代码来修复错误?

预先感谢您

+0

'$ wpdb->'似乎都不属于纯粹的SQL观点。但是,也许WordPress所做的与SQL意义不同。我也不确定'。$ comment_Posts;'是否希望实现。 – xQbert

+0

感谢您的输入sir –

+2

'$ comment_posts'似乎为空 –

回答

0

我得到了相似类型的问题,同时使用ORDER BY和在here所示的WordPress query.i重写查询限制。我认为wordpress有不同的结构,同时附加variable.try它。

+0

谢谢先生,我会检查出来 –