This is somewhat old news, but it seems people are still bitten by this problem. In some cases, osCommerce MS2 outputs SELECT queries with a negative LIMIT, eg:
SELECT whatever FROM mytable LIMIT -20,20
More and more servers come with MySQL 4.1. Unfortunately, LIMIT no longer accepts negative arguments and you get this strange message:
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
(If you've changed the configuration, you can get other values, eg '-10,10'). To be compatible with MySQL 4.1, you need to change includes/classes/split_page_results.php in both catalog and admin.
Locate this line in admin (l. 37 in the original file):
$offset = ($max_rows_per_page * ($current_page_number - 1));
and replace with:
$offset =
max($max_rows_per_page *
($current_page_number -
1),
0);
And in catalog (l. 65 in the original file):
$offset = ($this->number_of_rows_per_page * ($this->current_page_number - 1));
replace with:
$offset =
max($this->
number_of_rows_per_page *
($this->
current_page_number -
1),
0);
Thanks to cannuck1964 (Peter McGrath) for pointing out my error.