Page 1 of 1

Can't find problem -syntax error, unexpected '<

Posted: Thu Feb 07, 2013 5:31 pm
by rugguy
I have a problem with third party code that tracks affiliate sales. The code is placed within a page that is shown to the customer once they have successfully completed a transaction on our ecommerce site. When we insert the code this is the error message we get:

Parse error: syntax error, unexpected '<' in /homepages/xx/xxxxxxxx/htdocs/AFS/checkout_success.php on line 61

Here is the page code. The code we have to insert is in red. When we check the code through an online PHP code checker it says it's fine. The errors beg to differ. And help would be greatly appreciated (and no, the third party is no help).

Code: Select all

<?php
/*
$Id: checkout_success.php 1857 2012-06-20 01:21:38Z michael.oscmax@gmail.com $
  osCmax e-Commerce
  http://www.oscmax.com
  Copyright 2000 - 2011 osCmax
  Released under the GNU General Public License
*/
// Most of this file is changed or moved to BTS - Basic Template System - format.
// For adding in contribution or modification - parts of this file has been moved to: catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).
//       catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).
// (Sub 'fallback' with your current template to see if there is a template specific file.)
  require('includes/application_top.php');
/* One Page Checkout - BEGIN */
// if the customer is not logged on, redirect them to the shopping cart page
//  if (!tep_session_is_registered('customer_id')) {
//    tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
//  }
  if (ONEPAGE_CHECKOUT_ENABLED == 'True'){
      if (!tep_session_is_registered('onepage')){
          if (!tep_session_is_registered('customer_id')) {
              tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
          }
      }else{
          require(bts_select('language', FILENAME_CHECKOUT));
          require_once('includes/functions/password_funcs.php');
          require('includes/classes/onepage_checkout.php');
          $onePageCheckout = new osC_onePageCheckout();
          $onePageCheckout->createCustomerAccount();
      }
  }else{
      if (!tep_session_is_registered('customer_id')) {
          tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
      }
  }
/* One Page Checkout - END */
  if (isset($_GET['action']) && ($_GET['action'] == 'update')) {
    $notify_string = '';
    if (isset($_POST['notify']) && !empty($_POST['notify'])) {
      $notify = $_POST['notify'];
      if (!is_array($notify)) {
        $notify = array($notify);
      }
      for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
        if (is_numeric($notify[$i])) {
          $notify_string .= 'notify[]=' . $notify[$i] . '&';
        }
      }
      if (!empty($notify_string)) {
        $notify_string = 'action=notify&' . substr($notify_string, 0, -1);
    }
    }
    tep_redirect(tep_href_link(FILENAME_DEFAULT, $notify_string));
  }
  require(bts_select('language', FILENAME_CHECKOUT_SUCCESS));
  $breadcrumb->add(NAVBAR_TITLE_1);
  $breadcrumb->add(NAVBAR_TITLE_2);
  $global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'");
  $global = tep_db_fetch_array($global_query);
           
   <?
   // get order id
   $sql = "select orders_id from ".TABLE_ORDERS.
          " where customers_id='".(int)$customer_id.
          "' order by date_purchased desc limit 1";
   $omnistar_orders_query = tep_db_query($sql);
   $omnistar_orders = tep_db_fetch_array($omnistar_orders_query);
   $omnistar_order_id = $omnistar_orders['orders_id'];
 
   // get total amount of order
   $sql = "select value from ".TABLE_ORDERS_TOTAL.
          " where orders_id='".(int)$omnistar_order_id.
          "' and class='ot_subtotal'";
   $omnistar_orders_total_query = tep_db_query($sql);
   $omnistar_orders_total = tep_db_fetch_array($omnistar_orders_total_query);
   $omnistar_total_value = $omnistar_orders_total['value'];

   //get product ids
    $sql = "select products_id from " .TABLE_ORDERS_PRODUCTS.
          " where orders_id=".(int)$omnistar_order_id;
    $omnistar_orders_products_query = tep_db_query($sql);
    $omnistar_orders_products = '';
    while ($row = tep_db_fetch_array($omnistar_orders_products_query)) {
        $omnistar_orders_products .= $row['products_id'] . ',';
    }
    $omnistar_orders_products = substr($omnistar_orders_products, 0, -1);
 
   // draw invisible image to register sale
   if($omnistar_total_value != "" && $omnistar_order_id != "") {
   ?>       
   <script>
    function hideIF() {    
    document.getElementById('IF').style.display = '';
    }
    function getSaleInfo() {
    document.getElementById('st_code').innerHTML='<iframe src="https://flooringstea.myomnistar.com/salejs.php?amount=<?php echo $omnistar_total_value; ?>&transaction=<?php echo $omnistar_order_id; ?>" alt="" id=IF width=50 height=50 border="0" frameborder="0" onload="hideIF()">';
    }
    window.onload = getSaleInfo;
    </script>
    <div id="st_code"></div>
    <?php      
     }
    ?>
         
 
  if ($global['global_product_notifications'] != '1') {
    $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");
    $orders = tep_db_fetch_array($orders_query);
    $products_array = array();
    $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name");
    while ($products = tep_db_fetch_array($products_query)) {
      $products_array[] = array('id' => $products['products_id'],
                                'text' => $products['products_name']);
    }
  }
  $content = CONTENT_CHECKOUT_SUCCESS;
  include (bts_select('main')); // BTSv1.5
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Re: Can't find problem -syntax error, unexpected '<

Posted: Thu Feb 07, 2013 5:57 pm
by requinix
Posting Code in the Forums
You need to use [syntax=php][/syntax] tags when posting PHP code, otherwise we can't read it. Means you can't add color to the code yourself but here it's easy to spot what you tried to add. I added them for you now, please remember to do it for next time.

Code: Select all

  $global = tep_db_fetch_array($global_query);
           
   <?
   // get order id
   $sql = "select orders_id from ".TABLE_ORDERS.
You're trying to add PHP code in the middle of PHP code. <? and <?php are only for entering a PHP code block (and ?> is only for exiting a code block). You're already in PHP code so you don't need to include one again.

Re: Can't find problem -syntax error, unexpected '<

Posted: Fri Feb 08, 2013 6:54 am
by rugguy
Sorry....thanks. I will do that next time. And thanks for the tip.