After imploding $searches you end up with a query with up to 3 WHERE keywords in it. Removing the first two WHERE s should do the trick.