Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

SQL error 1064


ivan8r

Recommended Posts

When I access the account_history.php on my site (Nexxon Car Audio), I am getting an SQL 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 'select o.orders_id, o.orders_status, o.date_purchased, o.delive

 

select count(select o.orders_id, o.orders_status, o.date_purchased, o.delivery_name, ot.text as order_total, s.orders_status_name from orders o left join orders_total ot on (o.orders_id = ot.orders_id) left join orders_status s on (o.orders_status = s.orders_status_id and s.language_id = \'1\') where o.customers_id = \'4936\' and ot.class=\'ot_total\' order by orders_id DESC) as total

 

[TEP STOP]

 

This was working correctly before. Any idea what I can do to repair this?

 

Thanks!!!

Link to comment
Share on other sites

Ran the query on my own database, worked okay.

 

Just one thing the \' in the query did you put them in there, generally I enclose my sql statements in double quotes " so never any need for \'

 

i.e.

 

$MyQuery = "select * from mytable where thefield = 'Hello' ";

 

Have you amended the tables in anyway (check all those fields are in your tables)

Link to comment
Share on other sites

I had the same error when I added the

 

Step-By-Step Manual Order Entry

http://www.oscommerce.com/community/contributions,1589

 

the error occurs in the catalog/account_history.php

 

When I replace the orginal file it works,

 

OR when I

 

Replace the

 

$history_query = tep_db_query($history_query_raw);

 

with

 

$history_query = tep_db_query($history_query_raw);

 

 

AND

 

Replace

 

 

$history_query_raw = "select o.orders_id, o.date_purchased, o.delivery_name, ot.text as order_total , s.orders_status_name from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id) left join " . TABLE_ORDERS_STATUS . " s on (o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "') where o.customers_id = '" . $customer_id . "' and ot.class = 'ot_total' order by orders_id DESC";

 

 

 

 

WITH

 

$history_query_raw = "select o.orders_id, o.date_purchased, o.delivery_name, o.billing_name, ot.text as order_total, s.orders_status_name from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_TOTAL . " ot, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$customer_id . "' and o.orders_id = ot.orders_id and ot.class = 'ot_total' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' order by orders_id DESC";

 

 

IT WORKS!!!! :D

Link to comment
Share on other sites

I tried substituting your code snips, but I still got the same error. I was also a little confused in your post when you said,

 

When I replace the orginal file it works,

 

When you replace the original file with what? Just the snips you mentioned in your post, or an entire replacement file?

 

Also, if it helps anybody, I didn't add that contribution to my site. I have added Easy Populate and Glance (didn't work for me though).

 

Thanks!!

Link to comment
Share on other sites

I fixed it by redownloading OSC and replacing that file with a newer version. I still don't know what caused that error, but at least I found a fix!

 

Thanks for the help!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...