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 '-50, 50' at line 1
query=SELECT products.*, min(products_atts.price) as pricefrom, 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 left join products_images on products.prod_id=products_images.prod_id and products_images.firstimg=1 WHERE prodcat_weight.cat_id in (38,51,29,55,7,34,25,10,3) and products.hidden='0' group by order by prodcat_weight.weight DESC, desc LIMIT -50, 50