MySQL Error 20, -20 in osCommerce

By | May 26, 2008

Anna-Marie asks;

I went into the admin section to put some products on special & it says the following & I don’t know why it is there or how to fix it.

“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”

This is quite a common error and is to do with the version of MySQL that your host is using.  Basically it’s a bug in the osCommerce code…

To fix this is quite simple…I’m assuming you are using an older version of osCommerce such as MS2…

Open the following file: /includes/classes/split_page_results.php

Find this code:

[php]$sql_query .= ” limit ” . $offset . “, ” . $max_rows_per_page;[/php]

Change it to:

[php]$sql_query .= ” limit ” . max($offset, 0) . “, ” . $max_rows_per_page;[/php]

Also open the following file: /admin/includes/classes/split_page_results.php and make the exact same change!

2 thoughts on “MySQL Error 20, -20 in osCommerce

  1. Gary Post author

    Anna-marie – you are welcome.

Leave a Reply

Your email address will not be published.