1064 – SQL query error oscommerce

Published by

Posted on March 30, 2008

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

To fix this

In admin/includes/classes find split_page_results.php and – BACK IT UP then find the lines

$offset = ($max_rows_per_page * ($current_page_number – 1));
$sql_query .= ” limit ” . $offset . “, ” . $max_rows_per_page;

change to

$offset = ($max_rows_per_page * ($current_page_number – 1));
if ($offset < 0)
{
$offset = 0 ;
}
$sql_query .= ” limit ” . $offset . “, ” . $max_rows_per_page;

MySQL 4.1.xx handles negatives correctly (by forcing an error) in the code above unlike earlier versions of MySQL.

=========

Thanks to   Charles Kangethe on http://forums.oscommerce.com/index.php?showtopic=144095&hl=1064