First off - this fix is actually already recorded in the contributions section and many thanks to those who recorded it - but I don't think it is a contribution - rather a tip - Secondly the same problem has arisen for 4 people in a few days and I dare say it will happen to more as hosts migrate their mySQL databases to version 4.1.xx -
Hence I post here
If you get an error whilst creating \ modifying your database such that thro admin you delete all entries on a particular table you will likely get this 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
followed by something like
select manufacturers_id, manufacturers_name, manufacturers_image, date_added, last_modified from manufacturers order by manufacturers_name limit -20, 20
or
select banners_id, banners_title, banners_image, banners_group, status, expires_date, expires_impressions, date_status_change, date_scheduled, date_added from banners order by banners_title, banners_group limit -20, 20
depending on which table you have deleted all records from.
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.
Change (catalog/includes/classes/split_page_results.php around line 67) from:
$this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;to:
$this->sql_query .= " limit " . max($offset, 0) . ", " . $this->number_of_rows_per_page;
Both on the catalog side and the admin side changing $offset to max($offset, 0) is the "official" fix.
hth
Charles
Edited by Jan Zonjee, 26 July 2008 - 07:53 AM.









