WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] SQL database error

[Resolved] SQL database error

  • Help!

    I have the following showing up at the bottom of my site.

    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]
    SELECT COUNT(DISTINCT ID) FROM

    The site is http://www.jakelowen.com

    Any idea how to get rid of that?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Still unresolved.. Anyone have an idea where to start tinkering to fix this problem?

    As i investigate more I see that the error occurs on all pages (main page, monthly archives, and other added wordpress pages) but does not occur on a particular posts permalink –

    Does that help narrow it down for anybody?

    Chris_K
    Member

    @handysolo

    Still stumps me, but does cause a question to bubble up: What plugins are you running? And have you experimented with disabling some of ’em?

    Thanks handy –

    I tried disabling all of them – to no avail.

    i was running podpress, skippy.net’s backup and cron plugins.

    Chris_K
    Member

    @handysolo

    Well, now I reckon we’ll want to look at your theme’s footer.php. Would you be willing to put the contents of it in a pastebin somewhere and put a link to it here?

    Got it! I found the solution below:

    The problem and the way akamanu.com PHP Certified Web Developer fixed:

    Inside the file wp-includes/template-functions-links.php there is the following instruction around line 500:

    $numposts = $wpdb->get_var(”SELECT COUNT(DISTINCT ID) FROM $fromwhere”); However the variable $fromwhere is not always initialized when the instruction is executed.

    So we have changed the instruction to:

    if(isset($fromwhere)){ $numposts = $wpdb->get_var(”SELECT COUNT(DISTINCT ID) FROM $fromwhere”);}else{
    $numposts = 0;}

    Now, I only have one more question – How do i get next/previous links on my archive pages?

    I am closing this post and making a new one that is more specific to my new problem.

    Thanks everyone!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] SQL database error’ is closed to new replies.