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 hienthi=1 order by stt,id desc' at line 1syntax error: SELECT count(id) AS numrows FROM table_video where type='' and id_benh= and hienthi=1 order by stt,id desc