2016-03-04 65 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

謝謝先生,我會檢查出來 –