|
| Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more. |
|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Registered
Join Date: Dec 2004
Location: missouri
Posts: 6
Reputation: 5
|
1064 - You have an error in your SQL syntax
Hi,
I was checking my orders and found the error below. I haven't made any changes to oscommerce. Please help. Thanks. 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 select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from orders o left join orders_total ot on (o.orders_id = ot.orders_id), orders_status s where o.customers_id = '1' and o.orders_status = s.orders_status_id and s.language_id = '1' and ot.class = 'ot_total' order by orders_id DESC limit -20, 20 |
|
|
|
|
#2 |
|
Older not wiser
Join Date: Nov 2003
Location: Calgary, AB
Posts: 2,473
Reputation: 205
|
I'm pretty sure you can't have a negative number for the LIMIT Offset value.
The number -20 should probably be 0 (zero). I have no idea why it would have changed. |
|
|
|
|
#3 |
|
Registered
Join Date: Dec 2004
Location: missouri
Posts: 6
Reputation: 5
|
Thanks for the quick response. Were does the -20 value reside?
|
|
|
|
|
#4 |
|
XPW
Join Date: Jun 2002
Location: New Hampshire, USA
Posts: 9,464
Reputation: 265
|
I can't figure out which query you're using. The ones on orders.php don't include a limit clause. What page are you on when you get this error?
__________________
Steve |
|
|
|
|
#5 |
|
Posts: n/a
|
The fix for this is:
Edit these two files: admin/includes/classes/split_page_results.php /includes/classes/split_page_results.php Insert: if ($offset < 0) { $offset = 0 ; } Just before this line: $this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page; |
|
|
#6 |
|
Registered
Join Date: Dec 2004
Location: missouri
Posts: 6
Reputation: 5
|
That did it! What do you think happened?
The error occurred when I clicked on "Orders" while in admin. You guys are great. Thanks for the help. |
|
|
|
|
#7 |
|
XPW
Join Date: Jun 2002
Location: New Hampshire, USA
Posts: 9,464
Reputation: 265
|
Looks as if something was sending a "page 0" (or empty value) for the page number. That doesn't sound typical.
__________________
Steve |
|
|
|
|
#8 | |
|
Join Date: May 2004
Location: California
Posts: 57
Reputation: 8
|
Quote:
The culprit code is in osCommerce: $num_pages = ceil($query_num_rows / $max_rows_per_page); if ($current_page_number > $num_pages) { $current_page_number = $num_pages; } $offset = ($max_rows_per_page * ($current_page_number - 1)); in the case where there are no rows found to display (query_num_rows=0), the offset goes to negative max_rows_per_page. The posted fix compensates for this odd case, though a more logical fix would be to set numpages=1 if numpages=0. That is nitpicking though! |
|
|
|
|
|
#9 |
|
XPW
Join Date: Jun 2002
Location: New Hampshire, USA
Posts: 9,464
Reputation: 265
|
Thanks very much for this - I had not yet encountered it myself, but sure enough, I can reproduce it on my store and made the appropriate fixes.
__________________
Steve |
|
|
|
|
#10 |
|
Posts: n/a
|
Thank you so much for the help - I just had the same problem myself (I too have no idea why as I haven't changed anything) and was able to fix it after a few minutes spent here.
Once again everyone on these forums have proven themselves to be worth their weight in gold. Thank you!! Samantha ![]() |
|
|
#11 |
|
Posts: n/a
|
|
|
|
#12 | |
|
Registered
Join Date: May 2005
Location: In front of my screen
Posts: 25
Reputation: 1
|
Quote:
So, if you don't want to waste your time (and risk ending up with a non-working 'solution' because some postings there contain wrong information), don't read the postings but just use the solution provided here. |
|
|
|
|
|
#13 |
|
Registered
Join Date: May 2005
Location: In front of my screen
Posts: 25
Reputation: 1
|
This is in addition to the solution provided by Viscid.
It should be pointed out that the code in the admin section is not the same as the code in the store section, even though the files are named the same. In the admin file (admin/includes/classes/split_page_results.php), the code line to look for is PHP Code:
|
|
|
|
|
#14 |
|
Posts: n/a
|
nm edited post found fix.
|
|
|
#15 | |
|
Join Date: Apr 2003
Location: Everywhere! Currently Mallorca, Balearic Islands
Posts: 1,452
Reputation: 86
|
Same error, different place...
Hope someone can help me...
I just deleted all the products in Specials and, after the last one was gone, all I could get on the Specials page was: Quote:
Do I follow the same instructions from Viscid or must I do something else somewhere else? While I'm at it, I have noticed that, in spite of selecting a product for the shopping cart which shows up in the box in the right-hand column, the shopping cart page says that there are no products in the cart... any clues on mhy that would be happening? Thanks to anyone who can help - I am a novice at this stuff and finding it very difficult! Last edited by linnetwoods : 8-26-05 at 02:02 PM. |
|
|
|
|
|
#16 |
|
XPW
Join Date: Jun 2002
Location: New Hampshire, USA
Posts: 9,464
Reputation: 265
|
Same problem, same solution.
The cart problem is usually caused by an error in the configure.php for cookie domains.
__________________
Steve |
|
|
|
|
#17 |
|
Join Date: Apr 2003
Location: Everywhere! Currently Mallorca, Balearic Islands
Posts: 1,452
Reputation: 86
|
Thanks for the reply - actually, by the time I found it I had already found a solution to the Specials problem at OsCommerce.com bugs which worked perfectly and now I will address the cart problem...
Thanks again, ![]()
__________________
The pen is mightier than the sword. Except when the other guy has the sword ![]() LinnetWoods.com Your Website US Shopping Mall Innit Though? (my blog) |
|
|
|
|
#18 |
|
XPW
Join Date: Jun 2002
Location: New Hampshire, USA
Posts: 9,464
Reputation: 265
|
As I said, same problem, same solution.
__________________
Steve |
|
|
|
|
#19 |
|
Join Date: Apr 2003
Location: Everywhere! Currently Mallorca, Balearic Islands
Posts: 1,452
Reputation: 86
|
There seems to be no mention of cookies whatsoever in my configure.php, let alone one that includes http:// erroneously! I have been chasing around the osCommerce forums and elsewhere and have not managed to solve the problem so far. Any other advice you might be able to offer?Again, thanks for your previous effort.
__________________
The pen is mightier than the sword. Except when the other guy has the sword ![]() LinnetWoods.com Your Website US Shopping Mall Innit Though? (my blog) |
|
|
|
|
#20 |
|
XPW
Join Date: Jun 2002
Location: New Hampshire, USA
Posts: 9,464
Reputation: 265
|
You're probably looking in the wrong place. How about starting a new thread describing the problem and including the first 20 lines of catalog/includes/configure.php,
__________________
Steve |
|
|
![]() |
| Thread Tools | Search this Thread |
|
|