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 'LIMIT 36, 18' at line 21(No Description) sql: SELECT DISTINCT (p.id), IF(p.salesrank <> 0, p.salesrank, 100000) AS salesrank, p.price, p.linktitle, p.pagename, 'product' AS type FROM products p, products_categories c WHERE p.id = c.product_id AND p.parent_id = 0 AND c.category_id = 32 AND hidden = 0 AND enabled = 1 AND 1 = 1 UNION SELECT DISTINCT (p.id), IF(p.salesrank <> 0, p.salesrank, 100000) AS salesrank, p.price, p.linktitle, p.pagename, 'ebay' AS type FROM ebay_products p, products_categories c WHERE p.id = c.product_id AND c.category_id = 32 AND c.prod_type = 'ebay' AND p.hide = 1 UNION SELECT DISTINCT (p.id), IF(p.salesrank <> 0, p.salesrank, 100000) AS salesrank, p.price, p.linktitle, p.pagename, 'custom' AS type FROM custom_products p, products_categories c WHERE p.id = c.product_id AND c.category_id = 32 AND c.prod_type = 'custom' AND p.hide = 1 UNION SELECT DISTINCT (p.id), IF(p.salesrank <> 0, p.salesrank, 100000) AS salesrank, p.price, p.linktitle, p.pagename, 'bundle' AS type FROM bundles p, bundle_categories c WHERE p.id = c.bundle_id AND c.category_id = 32 AND disabled = 0 AND 1 = 1 ORDER BY LIMIT 36, 18