Can't execute query: 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 'range = 'n' or (range = 'y' and NOW() >= start_date and NOW() <= end_date) ' at line 3