• I’ve just upgraded to the new wordpress, and am having trouble restoring my front page to its former glory. With the settings left alone all posts appear fine, with no error message. If I try this, however:

    <?php
    $posts = get_posts(‘numberposts=5&offset=1&category=2’);
    foreach($posts as $post) :
    ?>
    “><?php the_title(); ?> — <?php the_excerpt(); ?>
    <?php endforeach; ?>

    This error message appears:

    WordPress database error: [You have an ; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘AND comment_approved = ‘1” at line 1]
    SELECT COUNT(comment_ID) FROM wp_comments WHERE comment_post_ID = AND comment_approved = ‘1’;

    can anyone tell me why? My aim is to have 1 posts from each of 5 categories on the front page, with links to 3-5 articles underneath.

    Thanks for your help.

The topic ‘‘error in your SQL syntax’ when using get_posts’ is closed to new replies.