MyBB Community Forums

Full Version: Weird SQL Error...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This error has been appearing in my error logs for a few weeks now.

SQL Error: 1064 - 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 t.visible>0 AND t.closed NOT LIKE 'moved|%'' at line 1
Query: SELECT COUNT(t.tid) AS resultcount FROM af_threads t WHERE t.tid IN () AND t.visible>0 AND t.closed NOT LIKE 'moved|%' 

It seems to come from the search.php file, with these two lines:

 $where_conditions = "t.tid IN (".$search['threads'].")";
                        $query = $db->simple_select("threads t", "COUNT(t.tid) AS resultcount", $where_conditions. " AND {$unapproved_where} AND t.closed NOT LIKE 'moved|%' {$limitsql}");

If $search['threads'] is empty, it would create the empty () in the SQL query, and thus make it fail. Not sure if this is a bug, or some configuration problem though.