Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have been personally maintaining the Search Everything plugin for WordPress since the authors stopped. I upgraded one of my sites to wp 3.7 today but i get this error when i search:

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 '))) AND ncca_wp_posts.post_type IN ('post', 'page', 'attachment', 'archive', 'r' at line 1]

SELECT DISTINCT SQL_CALC_FOUND_ROWS 
    ncca_wp_posts.* 
FROM ncca_wp_posts 
LEFT JOIN ncca_wp_term_relationships AS trel 
    ON ( ncca_wp_posts.ID = trel.object_id ) 
LEFT JOIN ncca_wp_term_taxonomy AS ttax 
    ON ( 
        ( ttax.taxonomy = 'category' 
            OR ttax.taxonomy = 'post_tag' 
            OR ttax.taxonomy = 'years' 
            OR ttax.taxonomy = 'archive-tags' 
            OR ttax.taxonomy = 'course'
        ) 
        AND trel.term_taxonomy_id = ttax.term_taxonomy_id
    ) 
LEFT JOIN ncca_wp_terms AS tter 
    ON (ttax.term_id = tter.term_id) 
LEFT JOIN ncca_wp_postmeta AS m 
    ON (ncca_wp_posts.ID = m.post_id) 
WHERE 1=1 
    AND ( 
        ( 
            ((())) 
            AND ncca_wp_posts.post_type IN ('post', 'page', 'attachment', 'archive', 'research-project') 
            AND (
                ncca_wp_posts.post_status = 'publish' 
                OR ncca_wp_posts.post_status = 'private'
            )
        ) 
        AND post_type != 'revision'
    )
    AND post_status != 'future' 
    ORDER BY ncca_wp_posts.post_title LIKE '% %' DESC, ncca_wp_posts.post_date DESC LIMIT 0, 24

Edit: Thank you kaiser. Taken on board for next time. I can see the error is being caused by an SQL syntax error, as stated above, but I cannot figure out how to fix it. Can anybody suggest how to alter this line of code to make it work correctly?

share|improve this question

closed as off-topic by Rarst Oct 27 '13 at 20:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

    
For future questions: Please format your question always as good as possible. Not only because it serves a purpose as reference for later readers as well, but also because you'll notice simple mistakes, typos and other road blocking, site breaking bugs by yourself. See the reformatted question and tell us what you think the problem might be - of course in an edit (not in a comment). Hint: The error message already tells a lot about what might be the problem. –  kaiser Oct 26 '13 at 19:58
2  
It looks like you have two ANDs in a row at the start of your WHERE clause. Why do you have the empty parentheses at the start? (ie, the ((())) bit?) –  Pat J Oct 26 '13 at 21:02
    
Sorted! I will post the relevant function to edit as an answer –  RoseCoder Oct 26 '13 at 21:28

1 Answer 1

Thanks to @Pat J i removed the syntax that was causing me problems. For those who are interested, inside the Search Everything plugin, on line 198 - 221 there is the following function:

    function se_search_default() {

    global $wpdb;

    $n = ( isset( $this->query_instance->query_vars['exact'] ) && $this->query_instance->query_vars['exact'] ) ? '' : '%';
    $search = '';
    $seperator = '';
    $terms = $this->se_get_search_terms();

    // if it's not a sentance add other terms

     //COMMENT OUT/REMOVE
    //$search .= '(';
    foreach ( $terms as $term ) {
        $search .= $seperator;


        $search .= sprintf( "((%s.post_title LIKE '%s%s%s') OR (%s.post_content LIKE '%s%s%s'))", $wpdb->posts, $n, $term, $n, $wpdb->posts, $n, $term, $n );

        $seperator = ' AND ';
    }
     //COMMENT OUT/REMOVE
    //$search .= ')';
    return $search;
}

If you are using the Search Everything plugin on WP 3.7, you will need to edit this function accordingly, or differently if you know better. ( I am merely a beginner ). Many thanks!!

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.