2
誰能幫我這個底部功能導致錯誤警告:缺少參數2 :: WPDB準備()
Warning: Missing argument 2 for wpdb::prepare(), called in /home/.../wp-content/themes/theme/display.php on line 233 and defined in /home/.../wp-includes/wp-db.php on line 1147
這是函數
function ts_display_getnumposts($cat){
global $wpdb;
$qryString = "
SELECT Count(*) as totpost FROM ".$wpdb->posts." a
INNER JOIN ".$wpdb->term_relationships." b ON a.ID = b.object_id
INNER JOIN ".$wpdb->term_taxonomy." c ON b.term_taxonomy_id = c.term_taxonomy_id
INNER JOIN ".$wpdb->terms." d ON c.term_id = d.term_id
WHERE a.post_type = 'display'
";
if(strlen($cat)>0){
$qryString .= " AND d.slug = '".$cat."'";
}
$numposts = $wpdb->get_var($wpdb->prepare($qryString));
return $numposts;
}
謝謝你閱讀我的問題。並預先感謝您的回覆。
錯誤消息說你錯過了調用prepare()方法的第二個參數。我也看不到第二個參數... – Madbreaks 2014-12-19 00:44:39