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.visible='1'' at line 1::SELECT c.contenidoID, c.fecha, c.tituloES as titulo, c.foto, c.detalleES as detalle, c.categoriaID, cat.categoriaES as categoria, cat.categoriaES from contenidos c INNER JOIN contenidos_categorias cat ON c.categoriaID=cat.categoriaID where c.contenidoID= and c.visible='1'