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 'ORDER BY id DESC' at line 1
: SELECT p.*, p.tit_ca as tit, p.url_ca as url, c.nom_ca as cattxt FROM treballs p, categories c WHERE c.id=p.cat AND cat= ORDER BY id DESC