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 's ORDER BY RAND() LIMIT 15' at line 1 SELECT lsm_catal_prod_id, lsm_catal_prod_nome, lsm_catal_prod_chamada, lsm_catal_prod_disponi, lsm_catal_prod_valorunit, lsm_catal_prod_valorpromo, lsm_catal_prod_statusdestaq, lsm_catal_prod_refeprod, lsm_catal_prod_catal_prod_cat,lsm_catal_prod_peso, lsm_catal_prod_visib, lsm_catal_valor_desc, lsm_catal_marc_nome,lsm_catal_prod_vale_compra FROM lsm_catal_produtos LEFT JOIN lsm_catal_marcas ON lsm_catal_produtos.lsm_catal_prod_catal_marc=lsm_catal_marcas.lsm_catal_marc_id WHERE lsm_catal_prod_id!='0' AND lsm_catal_prod_visib=1 AND lsm_catal_prod_catal_prod_cat = 14--santinho-nossa-senhora-desatadora-dos-nós ORDER BY RAND() LIMIT 15