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, 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 (824,845,841,843,844,1082,1081,1084,1083,828,827,826,849,848,847,851,871,874,872,873,1046,1045,1033,1029,1030,1031,1032,897,983,981,1056,970,975,977,974,978,976,979,982,980,1011,1185,1186,1187,823,1069,1065,1067,1132,1068,1066,1074,1072,1075,1076,1077,1078,1073,887,889,888,891,890,1053,1054,1059,1060,1061,1086,876,881,882,880,1118,1047,1058,1049,1051,1050,1048,1052,1044,1124,1149,1152,1151,1150,1079,811) and prodcat_weight.hidden='0' group by products.id order by prodcat_weight.weight ASC, id desc LIMIT -50, 50