Dear osCommerce Community
frst of all I have to say that this is really a great contribution. I am using it on two different osCommerce installations and it is working great.
On one of my osCmmerce webistes I have installed this Contrib with version 2.5 - and it is simply working perfectly there. The server for this page uses PHP 4.4.9 and MySQL 4.1.22
On my other osCmmerce webiste (which uses MySQL 4.0.25), I have discovered a problem with version 2.5 of this Contrib though - propably due to the MYSQL version on this server, which I unfortunately can´t change though, as the domain is hosted on a shared server and the hosting company won´t do any changes to it.
I have been able to install the updates of the "Discount Codes" Contrib up to version 2.4 ... and it works properly up to that version ... but when I do the update towards version 2.5, there occurs a TEP STOP erroe in the checkout_confirmation.php and the customers can´t complete their order. As version 2.5 includes some nice features such as unlimited usages of discount codes by a customer or including the discount code to the order info, I would like to get version 2.5 running on that server as well.
The TEP STOP error I receive in the checkout_confirmation.php with version 2.5 contains the following error message:
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 count(*) as total from discount_codes dc, customers_to_d<br><br>select if(number_of_use = 0, 1, if(a.total < number_of_use, 1, 0)) as result from discount_codes, (select count(*) as total from discount_codes dc, customers_to_discount_codes c2dc where dc.discount_codes_id = c2dc.discount_codes_id and dc.discount_codes = 'e2745e1c' and c2dc.customers_id = '1247') as a where discount_codes = 'e2745e1c' limit 1
I have sourced the reason for this error down to the ot_discount.php file in the folder catalog > includes > modules > order_total.php
The PHP code which causes this error must be somewhere in line 33:
$check_query = tep_db_query(sprintf("select if(number_of_use = 0, 1, if(a.total < number_of_use, 1, 0)) as result from %s, (select count(*) as total from %s dc, %s c2dc where dc.discount_codes_id = c2dc.discount_codes_id and dc.discount_codes = '%s' and c2dc.customers_id = '%s') as a where discount_codes = '%s' limit 1", TABLE_DISCOUNT_CODES, TABLE_DISCOUNT_CODES, TABLE_CUSTOMERS_TO_DISCOUNT_CODES, tep_db_input($sess_discount_code), (int)$customer_id, tep_db_input($sess_discount_code)));
I have tried to resolve this by myself for about nearly two days now - but as I am not being very skilled in PHP and MYSQL I just don´t find a way to resolve this error.
Does anyone have an idea what I would need to do or change in the code above in order to get rid of the error message and make this Contrib to work perfectly in version 2.5 as well on my server? Any hints are being much appreciated.
Thanks in advance,
Claud