SQL-DATABASE ERROR

Database error in WoltLab Burning Board: Invalid SQL: SELECT threadid FROM bb1_threads WHERE AND lastposttime<'1277318182' AND visible=1 AND closed <> 3 AND boardid = '251' ORDER BY lastposttime DESC LIMIT 0, 1
mysql 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 lastposttime<'1277318182' AND visible=1 AND closed <> 3 AND boardid = '251' ' at line 1
mysql error number: 1064
Date: 25.05.2019 @ 11:26
Script: /wbblite/thread.php?goto=nextoldest&threadid=2173
Referer: