roldahayes Posted November 7, 2013 Share Posted November 7, 2013 Hi, Can anyone point me in the right direction where I may be going wrong with the correct syntax in this code please? private function considerVouchers( $voucherCode ){//The voucher code value is checked to ensure it is not empty // (as per point 1)if( $voucherCode != '' ) // we need the date, to see if the voucher has expired$cts = date('Y-m-d H:i:s');$voucher_sql = "SELECT *, if('{$cts}' > expiry, 1, 0)AS expired FROM discount_codesWHERE vouchercode='{$voucherCode}' LIMIT 1";$this->registry->getObject('db')->executeQuery( $voucher_sql );if( $this->registry->getObject('db')->numRows() == 0 ){$this->voucher_notice = 'Sorry, the voucher code you enteredis invalid';}else{$voucher = $this->registry->getObject('db')->getRows();if( $voucher['active'] == 1 ){if( $voucher['expired'] == 1 ){$this->voucher_notice = 'Sorry, this voucher has expired';return false;}else{// check to see there are some vouchers, and customer// has enough in their basket (points 3 and 4)if( $voucher['num_vouchers'] != 0 ){if( $this->cost >= $voucher['min_basket_cost'] ){$this->discountCode = $voucherCode;$this->discountCodeId = $voucher['ID'];// If the discount operation is a percentage, then// the discount value is applied to the basket cost// to calculate that percentage. This amount is then// deducted from the order cost, giving a "discount// value"% discount from the order.if( $voucher['discount_operation'] == '%' ){$this->cost = $this->cost - (($this->cost)/100)*$voucher['discount_amount'];$this->voucher_notice = 'A ' . $voucher['discount_amount'] . '% discount has been applied to your order';return true;// If the discount operation is a subtraction, then // the discount amount from the discount code is // deducted from the order cost, and the order cost // is updated to reflect this.}elseif( $voucher['discount_operation'] == '-' ){$this->cost = $this->cost - $voucher['discount_amount'];$this->voucher_notice = 'A discount of £'. $voucher['discount_amount'] . ' has been applied to your order';return true;// Finally, if the discount operation is set to s // then, we set the shipping cost to the discount // value. This could allow us to set free shipping,// or just reduce shipping costs.}elseif( $voucher['discount_operation'] == 's' ){$this->shipping_cost = $voucher['discount_amount'];$this->voucher_notice = 'Your orders shipping costhas been reduced to £' . $voucher['discount_amount'];return true;}}else{$this->voucher_notice = 'Sorry, your order total is not enough for your order to qualify for this discount code';return false;}}else{$this->voucher_notice = 'Sorry, this was a limitededition voucher code, there are no more instancesof that code left';return false;}}}else{$this->voucher_notice = 'Sorry, the vocuher code youentered is no longer active';return false;}}}} Link to comment https://forums.phpfreaks.com/topic/283687-incorrect-syntax/ Share on other sites More sharing options...
Barand Posted November 7, 2013 Share Posted November 7, 2013 Give us a clue and post the entire error message Link to comment https://forums.phpfreaks.com/topic/283687-incorrect-syntax/#findComment-1457374 Share on other sites More sharing options...
roldahayes Posted November 7, 2013 Author Share Posted November 7, 2013 If only life was that easy.... No matter what I try, I cannot get an error message to appear - Just a blank screen, Dreamweaver code highlight is suggesting the syntax error is on line 1 but that is all I can see. Link to comment https://forums.phpfreaks.com/topic/283687-incorrect-syntax/#findComment-1457400 Share on other sites More sharing options...
Ch0cu3r Posted November 7, 2013 Share Posted November 7, 2013 I cannot get an error message to appear - Just a blank screen, Turn error reporting on in the php.ini or check your severs error log. Dreamweaver code highlight is suggesting the syntax error is on line 1 but that is all I can see. Don't rely on Dreamweaver telling you what the error is. Link to comment https://forums.phpfreaks.com/topic/283687-incorrect-syntax/#findComment-1457402 Share on other sites More sharing options...
roldahayes Posted November 7, 2013 Author Share Posted November 7, 2013 I have error reporting on in PHP.ini I have also tried turning on using .htaccess and also directly into the top of the page.... Nothing...... Link to comment https://forums.phpfreaks.com/topic/283687-incorrect-syntax/#findComment-1457405 Share on other sites More sharing options...
mac_gyver Posted November 7, 2013 Share Posted November 7, 2013 there's nothing technically wrong with the code you posted, provided it's part of a class definition. what sort of problem are you having that you are trying to solve? Link to comment https://forums.phpfreaks.com/topic/283687-incorrect-syntax/#findComment-1457407 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.