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 '-36, 36' at line 1
query=SELECT products.*, min(products_atts.price) as pricefrom, min(products_atts.pricex) as pricexfrom, count(products_atts.product_id) as attcount, products_images.filename as thefile from prodcat_weight inner join products on products.prod_id=prodcat_weight.prod_id left join products_atts on products.id=products_atts.product_id left join products_images on products.prod_id=products_images.prod_id and products_images.firstimg=1 WHERE prodcat_weight.cat_id in (151,152,156,153,127,143,131,142,186,128,130,117,119,120,121,122,182,144,154,167,148,149,147,145,160,132,133,137,135,157,159,193,194,162,198,158,191,192,195,138,141,189,139,140,116) and prodcat_weight.hidden='0' group by products.id order by prodcat_weight.weight ASC, id desc LIMIT -36, 36