Jump to content

Parse error: parse error, unexpected $.. ARGGGGG ** SOLVED **


jwk811

Recommended Posts

i took this out to see if this was the problem and it was.. can you tell me whats wrong with this?
[code]<?php

if (isset($_POST['optPayment'])) {
$optPayment = $_POST['optPayment'];


if ($optPayment == 'paypal') {
$paypal_checked = 'checked="checked"';
} else if ($optPayment == 'cod') {
$paypal_checked = '' ;
} else {
$paypal_checked = 'checked="checked"';
}
?>

<?php
if ($optPayment == 'cod') {
$cod_checked = 'checked="checked"';
} else if ($optPayment == 'paypal') {
$cod_checked = '';
} else {
$cod_checked = '';
}

} else {
$paypal_checked = 'checked="checked"';
$cod_checked = '';
?>[/code]
[quote author=jwk811 link=topic=113794.msg462728#msg462728 date=1162606361]
this is weird.. im getting this error: Parse error: parse error, unexpected $
on the very last line where it says </form>.. what could cause this
[/quote]

Symptomatic of an unclosed loop.  If you indent every loop it makes it much easier to spot when you fail to close them.,
[code]
<?php
if (isset($_POST['optPayment'])) {
    $optPayment = $_POST['optPayment'];
    if ($optPayment == 'paypal') {
$paypal_checked = 'checked="checked"';
    } else if ($optPayment == 'cod') {
$paypal_checked = '' ;
    } else {
$paypal_checked = 'checked="checked"';
    }
    if ($optPayment == 'cod') {
$cod_checked = 'checked="checked"';
    } else if ($optPayment == 'paypal') {
$cod_checked = '';
    }  //<--I think I just found it.
} else {
$cod_checked = '';
}
[/code]
It should read like this


[code]
<?php

if (isset($_POST['optPayment'])) {
    $optPayment = $_POST['optPayment'];

    if ($optPayment == 'paypal') {
          $paypal_checked = 'checked="checked"';
    } else if ($optPayment == 'cod') {
  $paypal_checked = '' ;
    } else {
$paypal_checked = 'checked="checked"';
    }
?>

<?php
    if ($optPayment == 'cod') {
$cod_checked = 'checked="checked"';
    } else if ($optPayment == 'paypal') {
$cod_checked = '';
    } else {
$cod_checked = '';
    }

} else {
$paypal_checked = 'checked="checked"';
$cod_checked = '';
} //YOU WERE MISSING THIS BRACKET...
?>

[/code]

you are missing the last bracket. Hope this helps

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.