I am working with this function and I get an unexpected ; parse error ... is my syntax wrong?
Here is my code where the error happens:
foreach ($productArray as $product) {
// Comment the string until it has proper form
$process_button_string = zen_draw_hidden_field('ItemQuantity',$product['quantityField'] .
zen_draw_hidden_field('ItemImage',$product['productsImage']) .
zen_draw_hidden_field('ItemDescription',$product['productsName']) .
zen_draw_hidden_field('ItemPrice',$product['productsPrice']);
// echo $process_button_string;
// $process_button_string .= zen_draw_hidden_field(zen_session_name(), zen_session_id());
return $process_button_string;
}
the unexpected ; is the one at the end of $process_button_string
Here is the complete code:
function process_button() {
global $_SERVER, $product;
$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if (($i/2) == floor($i/2)) {
$productsImage = (IMAGE_SHOPPING_CART_STATUS == 1 ? zen_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT) : '');
$quantityField = zen_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"');
$productsPrice = $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
$productsPriceEach = $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
// Create a smaller Array to hold just the data above
$productArray[$i] = array( 'productsImage'=>$productsImage,
'productsName'=>$productsName,
'quantityField'=>$quantityField,
'productsPrice'=>$productsPrice,
'productsPriceEach'=>$productsPriceEach,
'rowClass'=>$rowClass,
'id'=>$products[$i]['id']);
} // end FOR loop
foreach ($productArray as $product) {
// Comment the string until it has proper form
$process_button_string = zen_draw_hidden_field('ItemQuantity',$product['quantityField'] .
zen_draw_hidden_field('ItemImage',$product['productsImage']) .
zen_draw_hidden_field('ItemDescription',$product['productsName']) .
zen_draw_hidden_field('ItemPrice',$product['productsPrice']);
// echo $process_button_string;
// $process_button_string .= zen_draw_hidden_field(zen_session_name(), zen_session_id());
return $process_button_string;
}
}
and this is zen_draw_hidden_field() the function called in the loop.
// Output a form hidden field
function zen_draw_hidden_field($name, $value = '', $parameters = '') {
$field = '<input type="hidden" name="' . zen_output_string($name) . '"';
if (zen_not_null($value)) {
$field .= ' value="' . zen_output_string($value) . '"';
} elseif (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) {
$field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
}
if (zen_not_null($parameters)) $field .= ' ' . $parameters;
$field .= '>';
return $field;
}