Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Odd SQL errors on some servers


updmike

Recommended Posts

Posted

Hello,

 

Ive notice this for a while but could never understand it. On some servers when a query returns empty i get a sql error displayed in the store. It looks like it is turning the max results per page into a negative.

 

Here is an example in admin/orders.php when searching orders by a customer field. This particular cusotmer has no orders so it returns this error.

 

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 '-100, 100' 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 = '3833' and o.orders_status = s.orders_status_id and s.language_id = '1' and ot.class = 'ot_total' order by orders_id DESC limit -100, 100

 

Again, this is only with some servers. Anyone have any advice to what I should mention to my webhost?

 

thanks,

Mike

Posted

Found out how to fix this if anyone else is searching the forums for this problem.

 

It was posted 6 pages deep in a contribution forum thread, not related but works.

http://www.oscommerce.com/forums/index.php?s=&...ndpost&p=842793

 

1. open /includes/classes/split_page_results.php

 

2. locate the following line of code

$offset = ($this->number_of_rows_per_page * ($this->current_page_number - 1));

 

3. add the following code under the located line

if($offset < 0)

{

$offset = 0;

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...