Hello i am having some trouble with navigation on my wordpress site. Code is below. I mean everything is working fine, but error_log is constantly being updated with this: [12-Jan-2013 08:02:15] 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 '' at line 1 for query SELECT COUNT(DISTINCT ID) FROM made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/theme/index.php'), include('/themes/theme/library/includes/featured-page.php'), wp_pagenavi Can you help me somehow please ? Thank you in advance! function wp_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) { global $request, $posts_per_page, $wpdb, $paged, $totalpost_count, $posts_per_page_homepage, $postno; if($posts_per_page_homepage) { $posts_per_page = $posts_per_page_homepage; } if(empty($prelabel)) { $prelabel = '<strong>«</strong>'; } if(empty($nxtlabel)) { $nxtlabel = '<strong>»</strong>'; } $half_pages_to_show = round($pages_to_show/2); if (!is_single()) { if(is_tag()) { preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); } elseif (!is_category()) { preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches); } else { preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); } $fromwhere = $matches[1]; $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); } if($totalpost_count) { $numposts = $totalpost_count; } if($postno) { $numposts = $postno; } if($numposts > 1000000) { $numposts = 100; } $max_page = ceil($numposts /$posts_per_page); if(empty($paged)) { $paged = 1; } if($max_page > 1 || $always_show) { echo "$before <div class='Navi'>";; if ($paged >= ($pages_to_show-1)) { echo '<a href="'.get_pagenum_link().'">« '.FIRSTT.'</a>'; } previous_posts_link($prelabel); for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { if ($i >= 1 && $i <= $max_page) { if($i == $paged) { echo "<strong class='on'>$i</strong>"; } else { echo ' <a href="'.get_pagenum_link($i).'">'.$i.'</a> '; } } } next_posts_link($nxtlabel, $max_page); if (($paged+$half_pages_to_show) < ($max_page)) { echo '<a href="'.get_pagenum_link($max_page).'">'.LASTT.' »</a>'; } echo "</div> $after"; } } PHP:
isn't a valid SQL query. It looks as if someone edited one of your files and screwed up. If you can't find it (if you edited anything, look there), upload all your Wordpress files (other than the config file) again. Or restore the site from a backup you made before the problem started.
There is wrong value in $fromwhere which setting by $request. You can try add print_r($request).'<br />'.print_r($fromwhere); (only on your test server!) to find the problematic area in your code.
Hi Sano000. Sory for late reply. I was really sick for some time. Thank you very much for trying to help. This is what I get if I add the line you wrote: SELECT SQL_CALC_FOUND_ROWS wordpress_posts.ID FROM wordpress_posts INNER JOIN wordpress_term_relationships ON (wordpress_posts.ID = wordpress_term_relationships.object_id) WHERE 1=1 AND ( wordpress_term_relationships.term_taxonomy_id IN (200,210,220,230,240,250,260,270,280,290) ) AND wordpress_posts.post_type = 'post' AND (wordpress_posts.post_status = 'publish' OR wordpress_posts.post_status = 'private') GROUP BY wordpress_posts.ID ORDER BY wordpress_posts.post_date DESC LIMIT 0, 20wordpress_posts INNER JOIN wordpress_term_relationships ON (wordpress_posts.ID = wordpress_term_relationships.object_id) WHERE 1=1 AND ( wordpress_term_relationships.term_taxonomy_id IN (200,210,220,230,240,250,260,270,280,290) ) AND wordpress_posts.post_type = 'post' AND (wordpress_posts.post_status = 'publish' OR wordpress_posts.post_status = 'private') PHP: Do you maybe know what's wrong?