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 items.activ ORDER BY rand() LIMIT 8' at line 9SELECT SQL_CALC_FOUND_ROWS * ,iname_hu AS iname FROM items LEFT JOIN brands ON (brands.bid = items.bid) WHERE (cid_bp = ) AND items.activ ORDER BY rand() LIMIT 8