Guest Posted January 19, 2006 Posted January 19, 2006 PHP Version 4.3.10 In Admin panel Customers page, I click ORDERS button to see the orders of selected customer. If the customer has at least one order, there's no problem. However, if the customer doesn't have an order, the error below appears: URL: http://............/admin/orders.php?cID=1 1064 - 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 '-20, 20' at line 1 select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from orders o left join orders_total ot on (o.orders_id = ot.orders_id), orders_status s where o.customers_id = '1' and o.orders_status = s.orders_status_id and s.language_id = '1' and ot.class = 'ot_total' order by o.orders_id DESC limit -20, 20 [TEP STOP] These are some part of code in the orders.php: // KW - start : download controller if($HTTP_GET_VARS['listing']=="customers") { $sort_by = "o.customers_name"; } elseif($HTTP_GET_VARS['listing']=="customers-desc") { $sort_by = "o.customers_name DESC"; } elseif($HTTP_GET_VARS['listing']=="ottotal") { $sort_by = "ot.value"; } //{ $sort_by = "order_total"; } elseif($HTTP_GET_VARS['listing']=="ottotal-desc") { $sort_by = "ot.value DESC"; } //{ $sort_by = "order_total DESC"; } elseif($HTTP_GET_VARS['listing']=="id-asc") { $sort_by = "o.orders_id"; } elseif($HTTP_GET_VARS['listing']=="id-desc") { $sort_by = "o.orders_id DESC"; } elseif($HTTP_GET_VARS['listing']=="status-asc") { $sort_by = "o.orders_status"; } elseif($HTTP_GET_VARS['listing']=="status-desc") { $sort_by = "o.orders_status DESC"; } else { $sort_by = "o.orders_id DESC"; } // KW - end <?php if (isset($HTTP_GET_VARS['cID'])) { $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']); // KW - start : download controller // $orders_query_raw = "select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$cID . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by orders_id DESC"; $orders_query_raw = "select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$cID . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by " . $sort_by; // KW - end } elseif (isset($HTTP_GET_VARS['status'])) { ... From where the "LIMIT -20,20" is coming from? If I execute the SQL in phpMyAdmin without LIMIT -20,20 or with LIMIT 0,20 it works.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.