SELECT stores.id AS stores_id, stores.store_id, store_cookies.id, store_cookies.cookie FROM stores JOIN store_cookies ON stores.id = store_cookies.stores_id WHERE store_cookies.ip = 'ØIÙ\' ORDER BY last_activity DESC LIMIT 1 : 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 ''ØIÙ\' ORDER BY last_activity DESC LIMIT 1' at line 3