Avinitlarge Posted January 28, 2011 Share Posted January 28, 2011 Hi First of all, I know VERY little about PHP, The effort below is a wile guess that has gone wrong. I get this error Parse error: syntax error, unexpected T_IF in /home/repairyo/public_html/shop/includes/content/viewOrders.inc.php on line 57 I have no idea what ive done wrong, may be I am stupid for attempting it. Cheers Paul This is the original code $view_orders->assign('VAL_STATE',$lang['glob']['orderState_'.$orders[$i]['status']]); This is the modified code $view_orders->assign('VAL_STATE',$state = $results[$i]['status'] if ($state == '1') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '2') { "<font color='#009900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '4') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '5') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '6') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '7') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else { $lang['glob']['orderState_'.$orders[$i]['status']]); } Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/ Share on other sites More sharing options...
dragon_sa Posted January 28, 2011 Share Posted January 28, 2011 You havent closed the statement missing ); should be like this $view_orders->assign('VAL_STATE',$state = $results[$i]['status']); Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166765 Share on other sites More sharing options...
Avinitlarge Posted January 29, 2011 Author Share Posted January 29, 2011 Thanks, That got rid of the error. I still cant get it to work properly though. I don't know what I am doing wrong. If the order is has been cancelled, I should see cancelled in red in the order form which I thought would be the ($state =='6') but instead all I am seeing is the number 6 in black. I can't work out what ive done wrong, its frying my head. Ive altered the code from the above $view_orders->assign('VAL_STATE',$state = $orders[$i]['status']); if ($state == '1') { echo "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '2') { echo "<font color='#009900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '4') { echo "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '5') { echo "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($State == '6') { echo "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '7') { echo "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else { $lang['glob']['orderState_'.$orders[$i]['status']]; } $lv = !$langBully ? "lang" : "bully"; ${$lv}['glob'] = array( 'orderState_1' => "Pending (New Order)", 'orderState_2' => "Processing (See order notes)", 'orderState_3' => "Order Complete & Dispatched", 'orderState_4' => "Declined (See order notes)", 'orderState_5' => "Failed Fraud Review", 'orderState_6' => "Cancelled",] Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166783 Share on other sites More sharing options...
dragon_sa Posted January 29, 2011 Share Posted January 29, 2011 this else if ($State == '6') should be else if ($state == '6') Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166784 Share on other sites More sharing options...
Avinitlarge Posted January 29, 2011 Author Share Posted January 29, 2011 Ive just corrected that but it still isn't working as it should. Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166787 Share on other sites More sharing options...
dragon_sa Posted January 29, 2011 Share Posted January 29, 2011 what is the problem now? Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166793 Share on other sites More sharing options...
Avinitlarge Posted January 29, 2011 Author Share Posted January 29, 2011 Sorry, I should have said I have corrected the "S". I still see the number 6 instead of cancelled Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166795 Share on other sites More sharing options...
dragon_sa Posted January 29, 2011 Share Posted January 29, 2011 does it do that for all the different states, display the number instead of the message? Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166800 Share on other sites More sharing options...
Avinitlarge Posted January 29, 2011 Author Share Posted January 29, 2011 Yep, every one of them Here is the full page is it helps any better. Im on the verge of giving up if(!defined('CC_INI_SET')){ die("Access Denied"); } // include lang file $lang = getLang('includes'.CC_DS.'content'.CC_DS.'viewOrders.inc.php'); $lang = getLang('orders.inc.php'); // query database $view_orders=new XTemplate ('content'.CC_DS.'viewOrders.tpl'); $view_orders->assign('LANG_YOUR_VIEW_ORDERS',$lang['viewOrders']['your_orders']); $orders = $db->select('SELECT `status`, `cart_order_id`, `time`, `courier_tracking` FROM '.$glob['dbprefix'].'CubeCart_order_sum WHERE `customer_id` = '.$db->mySQLsafe($cc_session->ccUserData['customer_id']).' ORDER BY `time` DESC'); if ($orders) { $view_orders->assign('LANG_ORDER_LIST',$lang['viewOrders']['orders_listed_below']); $view_orders->assign('LANG_ORDER_NO',$lang['viewOrders']['order_no']); $view_orders->assign('LANG_STATUS',$lang['viewOrders']['status']); $view_orders->assign('LANG_DATE_TIME',$lang['viewOrders']['date_time']); $view_orders->assign('LANG_ACTION',$lang['viewOrders']['action']); $view_orders->assign('LANG_VIEW_ORDER',$lang['viewOrders']['view']); $view_orders->assign('LANG_COURIER_TRACKING', $lang['viewOrders']['courier_tracking']); for($i = 0, $maxi = count($orders); $i < $maxi; ++$i) { $state = $orders[$i]['status']; $orders[$i]['state'] = $lang['glob']['orderState_'.$state]; $view_orders->assign('TD_CART_CLASS',cellColor($i, 'tdcartEven', 'tdcartOdd')); $view_orders->assign('DATA',$orders[$i]); $view_orders->assign('VAL_STATE',$state = $orders[$i]['status']); if ($state == '1') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '2') { "<font color='#009900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '4') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '5') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '6') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '7') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else $lang['glob']['orderState_'.$orders[$i]['status']]; $view_orders->assign('VAL_DATE_TIME',formatTime($orders[$i]['time'])); if (!empty($orders[$i]['courier_tracking'])) { $view_orders->assign('TRACKING_URL', $orders[$i]['courier_tracking']); $view_orders->parse('view_orders.session_true.orders_true.repeat_orders.courier_tracking'); } if (in_array($orders[$i]['status'], array(1,4))) { $view_orders->assign('LANG_COMPLETE_PAYMENT',$lang['viewOrders']['complete_payment']); $view_orders->parse('view_orders.session_true.orders_true.repeat_orders.make_payment'); } $view_orders->parse('view_orders.session_true.orders_true.repeat_orders'); } for ($i=1; $i<=6; ++$i) { $view_orders->assign('LANG_ORDER_STATUS',$lang['glob']['orderState_'.$i]); $view_orders->assign('LANG_ORDER_STATUS_DESC',$lang['glob']['orderState_'.$i.'_desc']); $view_orders->parse('view_orders.session_true.orders_true.repeat_status'); } $view_orders->parse('view_orders.session_true.orders_true'); } else { $view_orders->assign('LANG_NO_ORDERS',$lang['viewOrders']['no_orders']); $view_orders->parse('view_orders.session_true.orders_false'); } $view_orders->assign('LANG_LOGIN_REQUIRED',$lang['viewOrders']['login_required']); if($cc_session->ccUserData['customer_id']>0) $view_orders->parse('view_orders.session_true'); else $view_orders->parse('view_orders.session_false'); $view_orders->parse('view_orders'); $page_content = $view_orders->text('view_orders'); ?> Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166802 Share on other sites More sharing options...
dragon_sa Posted January 29, 2011 Share Posted January 29, 2011 I believe your problem is the value in the array, even though you have the array values orderState_1 to 6, the array values you call actually start at 0 not 1 so the cancelled value would be state 5 not 6, this will be the same for all your orderState values a quick and dirty way to fix this is ${$lv}['glob'] = array( 'orderState_0' => "No Order", 'orderState_1' => "Pending (New Order)", 'orderState_2' => "Processing (See order notes)", 'orderState_3' => "Order Complete & Dispatched", 'orderState_4' => "Declined (See order notes)", 'orderState_5' => "Failed Fraud Review", 'orderState_6' => "Cancelled"); Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166804 Share on other sites More sharing options...
Avinitlarge Posted January 29, 2011 Author Share Posted January 29, 2011 ARGH!! Nope, that didn't work either Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166812 Share on other sites More sharing options...
dragon_sa Posted January 29, 2011 Share Posted January 29, 2011 did you change 'orderState_6' => "Cancelled",] to 'orderState_6' => "Cancelled"); Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166813 Share on other sites More sharing options...
Avinitlarge Posted January 29, 2011 Author Share Posted January 29, 2011 I have marked it ); but nothing. Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166818 Share on other sites More sharing options...
dragon_sa Posted January 29, 2011 Share Posted January 29, 2011 ok you are now missing some echo tags from what you posted originally, echo is what prints to the screen, also you have a value orderState 7 but no 7 in the array so change this part if ($state == '1') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '2') { "<font color='#009900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '4') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '5') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '6') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '7') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else $lang['glob']['orderState_'.$orders[$i]['status']]; to if ($state == '1') { echo "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '2') { echo "<font color='#009900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '3') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '4') { echo "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '5') { echo "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else if ($state == '6') { echo "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>"; } else { echo $lang['glob']['orderState_'.$orders[$i]['status']]; } you were also missing some curly brackets on the last else statement Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166847 Share on other sites More sharing options...
Avinitlarge Posted January 29, 2011 Author Share Posted January 29, 2011 Tried that and still nothing. Ive noticed I can remove whole bottom part of the code and it still only displays the numbers. Its as if the top part isnt connected with the bottom part. Top part $view_orders->assign('VAL_STATE',$state = $orders[$i]['status']); Link to comment https://forums.phpfreaks.com/topic/226007-noob-with-no-idea-unexpected-t_if-no-idea-what-ive-done-wrong/#findComment-1166916 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.