Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

SQL syntax error on empty table


adminarrival

Recommended Posts

Posted

I have a clean install with MySQL 4.1.7-0 .

 

I am getting the following error in the admin screen when I go to Catalog/specials

 

###########

Specials

 

Products Products Price Status Action

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 p.products_id, pd.products_name, p.products_price, s.specials_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status from products p, specials s, products_description pd where p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = s.products_id order by pd.products_name limit -20, 20

 

#############

 

If I go into mysql and add a record to the table the error goes away?

 

Does anyone know the fix?

Posted

OK after much more searching I found my own answer. It has to do with a negitive limit being used in the sql statement.

 

SinceI know people are going to hit this as they upgrade MySQL I will post this here. I found my answer at:

http://www.oscommerce.com/community/bugs,1...abase+(General)

 

My solution was to add :

 

if ($offset < 0)

{

$offset = 0 ;

}

Between:

$offset = ($max_rows_per_page * ($current_page_number - 1));

and:

$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;

 

in the file catalog/admin/includes/classes/split_page_results.php

 

I hope this helps :D

  • 2 weeks later...

Archived

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

×
×
  • Create New...