About Club osCommerce

Showcasing osCommerce…the good, the bad and the ugly!

Follow osc_pro on Twitter

MySQL Error 20, -20 in osCommerce

Written By Gary on May 26 2008 · Comments (2) Follow osc_pro on Twitter

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:
  1. $sql_query .= " limit " . $offset . ", " . $max_rows_per_page;

Change it to:

PHP:
  1. $sql_query .= " limit " . max($offset, 0) . ", " . $max_rows_per_page;

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


Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive - and you get a link from my homepage to your site. Cheers!


2 Comments

  1. Thank-you so very much, in under 2 minutes & it was fixed. Brilliant!

    Comment by Anna-marie — May 26, 2008 @ 9:41 am


  2. Anna-marie – you are welcome.

    Comment by Gary — May 26, 2008 @ 9:51 am


Leave a comment

RSS feed for comments on this post · TrackBack URL

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!