Jump to content

Parse error: parse error, unexpected '}'


jwk811

Recommended Posts

heres a big piece of this code
[code]// orders have been processed
// give the shopper intructions depending on what their payment method is
$paypal_message = 'PayPal Shopper';
$cod_message = 'COD Shopper';
$error_message = 'An Error Has Occured. Please Contact Live Chat For Assistance.';
// check payment method and assign different messages for each
if ($_SESSION['paypal']);
$content = $paypal_message;

} else if ($_SESSION['cod']);
$content = $cod_message;
} else {
echo '$error_message';

}
} else {
// something went wrong
$content = $error_message;[/code]
can you figure it out yet?
Link to comment
Share on other sites

You shouldnt put a semicolon after an if.
It should be this way-
[code]<?php
// orders have been processed
// give the shopper intructions depending on what their payment method is
$paypal_message = 'PayPal Shopper';
$cod_message = 'COD Shopper';
$error_message = 'An Error Has Occured. Please Contact Live Chat For Assistance.';
// check payment method and assign different messages for each
if ($_SESSION['paypal'])
$content = $paypal_message;

} else if ($_SESSION['cod'])
$content = $cod_message;
} else {
echo '$error_message';
} else {
// something went wrong
$content = $error_message;

?>[/code]

Orio.
Link to comment
Share on other sites

your problem lies with ur elseif statement... ur code should look like this:

[code=php:0]// orders have been processed
// give the shopper intructions depending on what their payment method is
$paypal_message = 'PayPal Shopper';
$cod_message = 'COD Shopper';
$error_message = 'An Error Has Occured. Please Contact Live Chat For Assistance.';
// check payment method and assign different messages for each
if ($_SESSION['paypal']) {
$content = $paypal_message;

} elseif ($_SESSION['cod']) {
$content = $cod_message;
} else {
echo '$error_message';

}
} else {
// something went wrong
$content = $error_message;
}
[/code]

edit:  crap sorry, you had missing braces all over the place.
Link to comment
Share on other sites

still not working.. heres the entire chunck of this script
[code]// 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");
}

// orders have been processed
// give the shopper intructions depending on what their payment method is
$paypal_message = 'PayPal Shopper';
$cod_message = 'COD Shopper';
$error_message = 'An Error Has Occured. Please Contact Live Chat For Assistance.';
// check payment method and assign different messages for each
if ($_SESSION['paypal']) {
$content = $paypal_message;

} elseif ($_SESSION['cod']) {
$content = $cod_message;
} else {
echo '$error_message';
}

} else {
// something went wrong
$content = $error_message;
}[/code]with this im now getting Parse error: parse error, unexpected '}' on line 38 which is where the } else { is
... any ideas?
Link to comment
Share on other sites

If you'll look at the if part you can see there's an extra brace. (I modified the spacing a bit so you can see it better):

[code]<?php
if ($shopConfig['sendOrderEmail'] == 'y')
{
//some code here
} //I think this brace isn't supposed to be here, and the one I marked as "meaing less" should be there

//more code here...

if ($_SESSION['paypal']) {$content = $paypal_message;}
elseif ($_SESSION['cod']) {$content = $cod_message;}
else {echo '$error_message';}

} //this brace is meaning less

else {$content = $error_message;}

?>[/code]

Look at the comments in the script, they're important.

Orio.
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.