• Resolved Jay

    (@the_circle_pit)


    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?‘;

    }

    //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 . ‘ ‘;

    } else {

    echo ‘ ‘ . $i . ‘ ‘;

    }

    }

    }

    if (($paged + $half_pages_to_show) < ($max_page)) {

    echo ‘?Last ?‘;

    }

    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

    (@the_circle_pit)

    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

    (@the_circle_pit)

    resolved

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Confusing Error_log entry’ is closed to new replies.