Apr 18 2014 
Support Center » Knowledgebase » Third Party Applications » OsCommerce - 1064 - You have an error in your SQL syntax
 OsCommerce - 1064 - You have an error in your SQL syntax
Solution Source: This article was taken from a forum entry in http://forums.oscommerce.com/index.php?showtopic=144095 , written by Charles Kangethe of Suffolk, England.
Retrieved: August 30, 2007.

Error

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
Resolution

Mysql 4.1 does not allow negative numbers for limits. As such numbers make no sense, this would be a bugfix, from a mysql point of view.

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.


Article Details
Article ID: 131
Created On: Jan 23 2009 06:25 PM

 This answer was helpful  This answer was not helpful

 Back
 Login [Lost Password] 
Email:
Password:
Remember Me:
 
 Search
 Article Options
Home | Register | Knowledgebase
Language:

Help Desk Software By Kayako eSupport v3.60.02