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 's_residence_(ca_only).html%' order by id limit 1' at line 1: select user_id from instution_ipaddress where is_verified = 1 and referer_check LIKE 'http://randstatestats.org/ca/stats/birth_by_mother's_residence_(ca_only).html%' order by id limit 1