You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') group by product_id' at line 1
query=select count(*) as comcount, avg(stars) as comavg, product_id from prodcomments where approved='1' and product_id in () group by product_id