Title: Confusing Error_log entry
Last modified: August 30, 2016

---

# Confusing Error_log entry

 *  Resolved [Jay](https://wordpress.org/support/users/the_circle_pit/)
 * (@the_circle_pit)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/confusing-error_log-entry/)
 * Hello,
 * When i check my error_log, I see to following error.
 * 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/movite/
   search.php’), include(‘/themes/movite/includes/paginate.php’), custom_wp_pagenavi
 * In my functions.php for custom_wp_pagenavi is the below code.
 * ////////////////////////////////////////////////////////////////////////////////
   //
   WP-PageNavi ////////////////////////////////////////////////////////////////////////////////
 * function custom_wp_pagenavi($before = ”, $after = ”, $prelabel = ”, $nxtlabel
   = ”, $pages_to_show = 5, $always_show = false)
    {
 *  global $request, $posts_per_page, $wpdb, $paged;
 *  if (empty($prelabel)) {
 *  $prelabel = ‘**«**‘;
 *  }
 *  if (empty($nxtlabel)) {
 *  $nxtlabel = ‘**»**‘;
 *  }
 *  $half_pages_to_show = round($pages_to_show / 2);
 *  if (!is_single()) {
 *  if (!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”);
 *  $max_page = ceil($numposts / $posts_per_page);
 *  if (empty($paged)) {
 *  $paged = 1;
 *  }
 *  if ($max_page > 1 || $always_show) {
 *  echo “$before <div class=\”wp-pagenavi\”><span class=\”pages\”>Page $paged of
   $max_page:</span>”;
 *  if ($paged >= ($pages_to_show – 1)) {
 *  echo ‘[« First](https://wordpress.org/support/topic/confusing-error_log-entry/&apos; . get_pagenum_link() . &apos;page/1?output_format=md)‘;
 *  }
 *  //previous_posts_link($prelabel);
 *  for ($i = $paged – $half_pages_to_show; $i <= $paged + $half_pages_to_show; 
   $i++) {
 *  if ($i >= 1 && $i <= $max_page) {
 *  $url = get_pagenum_link();
 *  if ($i == $paged) {
 *  echo “<strong class=’current’>$i”;
 *  } else if (substr($url, -1) == ‘/’) {
 *  echo ‘ [‘ . $i . ‘](https://wordpress.org/support/topic/confusing-error_log-entry/&apos; . $url . &apos;page/&apos; . $i . &apos;?output_format=md)‘;
 *  } else {
 *  echo ‘ [‘ . $i . ‘](https://wordpress.org/support/topic/confusing-error_log-entry/&apos; . $url . &apos;/page/&apos; . $i . &apos;?output_format=md)‘;
 *  }
 *  }
 *  }
 *  if (($paged + $half_pages_to_show) < ($max_page)) {
 *  echo ‘ [Last »](https://wordpress.org/support/topic/confusing-error_log-entry/&apos; . get_pagenum_link($max_page) . &apos;?output_format=md)‘;
 *  }
 *  echo “</div> $after”;
 *  }
 *  }
 * }
 * If you need more code from other files, just ask. This has been happening for
   a while now and I am just getting around to fixing it. There have been to many
   changes to the site for me to pin point what stated the error. Als, it seems 
   as the error is “cut off” in the error_log since there is not closing “)”

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Jay](https://wordpress.org/support/users/the_circle_pit/)
 * (@the_circle_pit)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/confusing-error_log-entry/#post-6382468)
 * i believe there is an error with the call..
 * $numposts = $wpdb->get_var(“SELECT COUNT(DISTINCT ID) FROM $fromwhere”);
 * in the above code, but i could be wrong.
 *  Thread Starter [Jay](https://wordpress.org/support/users/the_circle_pit/)
 * (@the_circle_pit)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/confusing-error_log-entry/#post-6382707)
 * resolved

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Confusing Error_log entry’ is closed to new replies.

## Tags

 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [Jay](https://wordpress.org/support/users/the_circle_pit/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/confusing-error_log-entry/#post-6382707)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
