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 'and c.ID_Reklamy=r.ID_reklamy' at line 7 SQL: SELECT c.nazwa, c.nazwa_seo, ID_cat, ID_cat_parent, r.nazwa reklama_nazwa, url reklama_url FROM 1_cat c, reklamy r WHERE ID_cat= and c.ID_Reklamy=r.ID_reklamy