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 'contact.html' and location = 'Main' and active='Y' and active_date < NOW() and (' at line 1