Jump to content

Syntax parse error


sccot

Recommended Posts

Hey guys

 

im making and order confirmation email send out, but i'm getting this syntax error with unexpected } on line 104. I think this is because loop 'for {' where i want to generate items ordered into the table. can anyone help me find out what is wrong or how can i add loop into the email message body. thanks

<?php
require_once 'library/config.php';

// if no order id defined in the session
// redirect to main page
if (!isset($_SESSION['orderId'])) {
   header('Location: ' . WEB_ROOT);
   exit;
}

$pageTitle   = 'Checkout Completed Successfully';
require_once 'include/header.php';
require_once 'library/cart-functions.php';


// send notification email
if ($shopConfig['sendOrderEmail'] == 'y') {
   $subject = "[New Order] " . $_SESSION['orderId'];
   $email   = $shopConfig['email'];
   $message = "You have a new order. Check the order detail here \n http://" . $_SERVER['HTTP_HOST'] . WEB_ROOT . 'admin/order/index.php?view=detail&oid=' . $_SESSION['orderId'] ;
   mail($email, $subject, $message, "From: $email\r\nReturn-path: $email");
}
$order_id = $_SESSION['orderId'];
$sql = "SELECT od_email FROM tbl_order WHERE od_id = $order_id";
$result = dbQuery($sql);
$row = dbFetchAssoc($result);
extract($row);
$status="Paid";
$sql = "UPDATE tbl_order
            SET od_status = '$status', od_last_update = NOW()
            WHERE od_id = $orderId";
    $result = dbQuery($sql);

$sql = "SELECT pd_name, pd_price, od_qty
       FROM tbl_order_item oi, tbl_product p 
      WHERE oi.pd_id = p.pd_id and oi.od_id = $orderId
      ORDER BY od_id ASC";

$result = dbQuery($sql);
$orderedItem = array();
while ($row = dbFetchAssoc($result)) {
   $orderedItem[] = $row;
}


// get order information
$sql = "SELECT od_date, od_last_update, od_status, od_shipping_first_name, od_shipping_last_name, od_shipping_address1, 
               od_shipping_address2, od_shipping_phone, od_shipping_state, od_shipping_city, od_shipping_postal_code, od_shipping_cost, 
            od_payment_first_name, od_payment_last_name, od_payment_address1, od_payment_address2, od_payment_phone,
            od_payment_state, od_payment_city , od_payment_postal_code,
            od_memo
       FROM tbl_order 
      WHERE od_id = $orderId";

$result = dbQuery($sql);
extract(dbFetchAssoc($result));
   

$subject_c = "Your purchased items on our website";
   $email_c   = $od_email;
   $headers  = 'MIME-Version: 1.0' . "\r\n";
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
   $headers .= 'Bcc: email@gmail.com' . "\r\n";
   $message_c = "<p> </p>

    <table width=\"550\" border=\"1\"  align=\"center\" cellpadding=\"5\" cellspacing=\"1\" class=\"detailTable\">
        <tr> 
            <td colspan=\"2\" align=\"center\" id=\"infoTableHeader\">Order Detail</td>
        </tr>
        <tr> 
            <td width=\"150\" class=\"label\">Order Number</td>
            <td class=\"content\">" . $orderId . "</td>
        </tr>
        <tr> 
            <td width=\"150\" class=\"label\">Order Date</td>
            <td class=\"content\">". $od_date . "</td>
        </tr>
        <tr> 
            <td class=\"label\">Status</td>
            <td class=\"content\">" . $orderId ."></td>
        </tr>
    </table>
   
   <p> </p>
<table width=\"550\" border=\"0\"  align=\"center\" cellpadding=\"5\" cellspacing=\"1\" class=\"detailTable\">
    <tr id=\"infoTableHeader\"> 
        <td colspan=\"3\">Ordered Item</td>
    </tr>
    <tr align=\"center\" class=\"label\"> 
        <td>Item</td>
        <td>Unit Price</td>
        <td>Total</td>
    </tr>".
    
$numItem  = count($orderedItem);
$subTotal = 0;
for ($i = 0; $i < $numItem; $i++) {
   extract($orderedItem[$i]);
   $subTotal += $pd_price * $od_qty;
"<tr class=\"content\"> 
        <td>". $od_qty . " x " . $pd_name ."</td>
        <td align=\"right\">". displayAmount($pd_price). "</td>
        <td align=\"right\">". displayAmount($od_qty * $pd_price). "</td>
    </tr>". } ."</table>";
   
   
   
   
   mail($email_c, $subject_c, $message_c, $headers);
require_once 'include/top.php'; ?>
<div class="main">
<table width="851"><tr><td valign="top" id="leftnav">
    
<ul>
<li><a href="/eshop/">« eShop</a></li></ul></td><td> 
<p> </p><table width="500" border="0" align="center" cellpadding="1" cellspacing="0" class="cat">
   <tr> 
      <td align="left" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr> 
               <td align="center"> <p> </p>
                        <h2>Thank you for shopping with us!</h2> <p>We will send the purchased 
                            item(s) right after your payment is completed. Your order number is: <b><?php echo $_SESSION['orderId']; ?></b>. Order confirmation email was sent to <b><?php echo $od_email; ?></b></p>
                  <p> </p></td>
            </tr>
         </table></td>
   </tr>
</table>
<br>
<br>

</td><td  valign="top" width="130" id="mcart">
  <?php require_once 'include/miniCart.php'; ?></td></tr></table>
  
  

<?php
require_once 'include/footer.php';
unset($_SESSION['orderId']); ?>

Link to comment
Share on other sites

You can't close a loop in the middle of the string.  The for loop needs to look like this:

for ($i = 0; $i < $numItem; $i++) {
   extract($orderedItem[$i]);
   $subTotal += $pd_price * $od_qty;
   $message_c += "<tr class=\"content\"> 
        <td>". $od_qty . " x " . $pd_name ."</td>
        <td align=\"right\">". displayAmount($pd_price). "</td>
        <td align=\"right\">". displayAmount($od_qty * $pd_price). "</td>
    </tr>";
}
$message_c += "</table>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.