You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 's#%' AND p_show_siamshop='yes' and p_pause = '' and p_stop = 0' at line 3select count(*) as count_p from product where cat_id LIKE '%#Carter's#%' AND p_show_siamshop='yes' and p_pause = '' and p_stop = 0