If this is your first visit, check our documentation. To post, register or login.
Forums / Code Matters / Bug Reports / SQL syntax bug in order.php with fix/patch for older MySQL

SQL syntax bug in order.php with fix/patch for older MySQL

Locked

Started by n8v on 26 May 2006, 6:29 AM · Views: 6,529

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
26 May 2006, 6:29 AM
#1
n8v avatar

n8v

New Zenner

Join Date:
Apr 2006
Posts:
4
Plugin Contributions:
0

SQL syntax bug in order.php with fix/patch for older MySQL

I have an older MySQL installation (v. 3.23.58) on my host (I don't know if newer version don't have this problem), and the checkout was breaking on step 1 with this error message:

1064 You have an error in your SQL syntax near '(zen_address_book ab left join zen_zones z o' at line 7
in:
[select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from zen_customers c, (zen_address_book ab left join zen_zones z on (ab.entry_zone_id = z.zone_id) left join zen_countries co on (ab.entry_country_id = co.countries_id) ) where c.customers_id = '2' and ab.customers_id = '2' and c.customers_default_address_id = ab.address_book_id]

I tracked it down to the parentheses around the phrase following "from zen_customers c, ". I removed them from includes/classes/order.php and it works now.

Here is the output of 'diff -ub', hopefully it won't wrap too badly:

--- order.php-dist      2006-05-25 22:10:07.000000000 -0800
+++ order.php   2006-05-25 22:15:22.000000000 -0800
@@ -235,9 +235,9 @@
                                     z.zone_name, co.countries_id, co.countries_name,
                                     co.countries_iso_code_2, co.countries_iso_code_3,
                                     co.address_format_id, ab.entry_state
-                                   from " . TABLE_CUSTOMERS . " c, (" . TABLE_ADDRESS_BOOK . " ab
+                                   from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab
                                    left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
-                                   left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) )
+                                   left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) 
                                    where c.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                    and ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                    and c.customers_default_address_id = ab.address_book_id";

I hope that helps someone else! It would probably be a good candidate for the code base too but I don't know who is in charge of that :)

-n

26 May 2006, 6:35 AM
#2
n8v avatar

n8v

New Zenner

Join Date:
Apr 2006
Posts:
4
Plugin Contributions:
0

Re: SQL syntax bug in order.php with fix/patch for older MySQL

oh yeah - what is the preferred method for submitting patches?

-n

27 May 2006, 6:59 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: SQL syntax bug in order.php with fix/patch for older MySQL

this is peculiar ... those parentheses were added to support MySQL 5 :wacko:

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

28 May 2006, 7:18 AM
#4
n8v avatar

n8v

New Zenner

Join Date:
Apr 2006
Posts:
4
Plugin Contributions:
0

Re: SQL syntax bug in order.php with fix/patch for older MySQL

rats, I wish I had a MySQL 5 server to experiment with and find a happy compromise.