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 'and status and parent_id = 0 and (access = 1 OR access = 3) order by ord' at line 1 Query:Select count(*) from products where cat_id = and status and parent_id = 0 and (access = 1 OR access = 3) order by ord