Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

SQL Syntax


Recommended Posts

When I go into administration in the customer order section here is what I get and I have no idea how to do whatever needs to be done to correct this or how to do it:

 

REPORTS

 

Best Customer Orders-Total

 

No. Customers Total Purchased

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 c.customers_firstname, c.customers_lastname, sum(op.products_quantity * op.final_price) as ordersum from customers c, orders_products op, orders o where c.customers_id = o.customers_id and o.orders_id = op.orders_id group by c.customers_firstname, c.customers_lastname order by ordersum DESC limit -20, 20

 

 

 

Best Products Purchased

 

No. Products Purchased

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 p.products_id, p.products_ordered, pd.products_name from products p, products_description pd where pd.products_id = p.products_id and pd.language_id = '1' and p.products_ordered > 0 group by pd.products_id order by p.products_ordered DESC, pd.products_name limit -20, 20

 

 

HEADING_TITLE

 

TABLE_HEADING_NUMBER TABLE_HEADING_PRODUCTS TABLE_HEADING_VIEWED

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 p.products_id, pd.products_name, pd.products_viewed, l.name from products p, products_description pd, languages l where p.products_id = pd.products_id and l.languages_id = pd.language_id order by pd.products_viewed DESC limit -20, 20

Link to comment
Share on other sites

When I go into administration in the customer order section here is what I get and I have no idea how to do whatever needs to be done to correct this or how to do it:

 

REPORTS

 

Best Customer Orders-Total 

 

No. Customers Total Purchased 

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 c.customers_firstname, c.customers_lastname, sum(op.products_quantity * op.final_price) as ordersum from customers c, orders_products op, orders o where c.customers_id = o.customers_id and o.orders_id = op.orders_id group by c.customers_firstname, c.customers_lastname order by ordersum DESC limit -20, 20 

 

Best Products Purchased 

 

No. Products Purchased 

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 p.products_id, p.products_ordered, pd.products_name from products p, products_description pd where pd.products_id = p.products_id and pd.language_id = '1' and p.products_ordered > 0 group by pd.products_id order by p.products_ordered DESC, pd.products_name limit -20, 20

 

 

HEADING_TITLE 

 

TABLE_HEADING_NUMBER TABLE_HEADING_PRODUCTS TABLE_HEADING_VIEWED 

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 p.products_id, pd.products_name, pd.products_viewed, l.name from products p, products_description pd, languages l where p.products_id = pd.products_id and l.languages_id = pd.language_id order by pd.products_viewed DESC limit -20, 20

 

Actually, the above pertained to the REPORTS section. I also have the below problem when going into the CUSTOMERS section:

 

Orders Order ID:

Status: All OrdersPendingProcessingDelivered

 

 

Customers Order Total Date Purchased Status Action

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.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.orders_status = s.orders_status_id and s.language_id = '1' and ot.class = 'ot_total' order by o.orders_id DESC limit -20, 20

Link to comment
Share on other sites

It could be that your splitpageresults class is not working properly because of a variable not being passed (php 5 ? change in ini settings ?).

 

You can solve this by adding a check to split_page_results class towards the end.

If tte lower limit < 0 set it to 0.

 

I remember seeing something like this on one of my clients sides that was solved like this ...

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

In includes/classes/split_page_results.php (admin and/or catalog section)

Change from

      $offset = ($this->number_of_rows_per_page * ($this->current_page_number - 1));

     $this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;

 

To

      $offset = ($this->number_of_rows_per_page * ($this->current_page_number - 1));

     if ($offset < 0) { $offset = 0; }

     $this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;

 

Make sure your page browsing is fully functional. This quick fix might get you to see the first page, but something more serious might still be wrong causing you not to seee page 2, 3, 4, ...

 

HTH

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...