Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

SQL error


Rhianwen

Recommended Posts

Posted

I've just installed osCommerce, haven't touched anything, but the Orders module gives me an error when I click on it (its the only one that has a problem)

 

It says

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.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.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

 

My server is running MySQL version 4.1.12. Can anybody help me fix this please?

 

Thanks!!

Posted

I can't find anything helpful in the Knowledge Base - it provides help on error 1046 but not 1064.

 

Is the security update you're referring to in osCommerce 2.2 Milestone 2 Update 051113?

Posted

Oh my goodness.... after hours and hours of searching I finally found something helpful, so for everyone else who has this problem I'm putting what I found on the forum so its a little easier to find.

 

From http://www.oscommerce.com/community/bugs,1605

 

Make sure

if ($offset < 0)

{

$offset = 0 ;

}

is 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 and in

catalog/includes/classes/split_page_results.php

 

Works for me!

Posted

The actual fix should be to change

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

to this

$sql_query .= " limit " . max($offset,0) . ", " . $max_rows_per_page;

As for it being in the forums, this question probably gets asked 3-4 times a month, if not more. So the answer is already in the forums, as are most.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Posted
As for it being in the forums, this question probably gets asked 3-4 times a month, if not more. So the answer is already in the forums, as are most.

 

Jack

 

3-4 times a month? probably 10 times a day. There should be a sticky post right at the top about it.

Posted

I was pretty sure when I posted it that it had been in the forums before, but when you have spent several hours looking through the forums and can't find an answer, it gets frustrating. I was hoping someone would be nice enough to help me out. If this problem is so common that it gets asked 10 times a day, maybe it should be easier to find!!

Posted

A good tip for searching the forums is to use your Google Toolbar (if you haven't installed it, do so).

 

For this search you'd have put this into the Google Search Box "1064 - You have an error in your SQL syntax" and selected 'Current Site' to search from, and you'd have got your answer in minutes.

 

Vger

Archived

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

×
×
  • Create New...