parse error, unexpected $

Discussion in 'PHP' started by Superior, May 29, 2007.

  1. #1
    Hello

    i am getting this error in my php script

    Parse error: parse error, unexpected $ in
    /ecommerce/home.catalog.php on line 1522


    the same script i have uploaded on any other script. where it is working fine.
    the other modules of the same script are working fine. but one module is not working and giving this error.

    please give me any idea about it.
     
    Superior, May 29, 2007 IP
  2. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #2
    We'd need to see the code to tell you anything.
     
    dp-user-1, May 29, 2007 IP
  3. wing

    wing Active Member

    Messages:
    210
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Check the file home.catalog.php on line 1522 and some lines above.
    Most likely the source of the errormessage is to be found there.

    Also sometimes erroneus linebreaks or similar can happen on upload.

    Had that problem earlier today actually with a script I moved between servers. Reuploading did not help and I had to fix it manually.

    If you cannot find and correct the error you can post an excerpt of the code so we can take a look : )
     
    wing, May 29, 2007 IP
  4. mrmonster

    mrmonster Active Member

    Messages:
    374
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Some advice, it's never a good idea to post system paths on a public forum due to security issues.
     
    mrmonster, May 29, 2007 IP
  5. Superior

    Superior Well-Known Member

    Messages:
    488
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #5
    Thanks all of you

    1522 line is the last line of page.

    here is code from line 1400 to line 1522.
    ";

    /*** RFQ Only ***/
    if ($oSystem->getValue("ecommerce_tr_rfqenable")=="Yes" && $oSystem->getValue("ecommerce_tr_ccenable")!="Yes" && $oSystem->getValue("ecommerce_tr_poenable")!="Yes" && $oSystem->getValue("ecommerce_tr_cheque")!="Yes" && $oSystem->getValue("ecommerce_tr_wiretransfer")!="Yes" && $oSystem->getValue("ecommerce_tr_moneyorder")!="Yes" && $oSystem->getValue("ecommerce_tr_offlinecc")!="Yes" && $oSystem->getValue("ecommerce_tr_cod")!="Yes" && $oSystem->getValue("ecommerce_tr_phoneorder")!="Yes" && $oSystem->getValue("ecommerce_tr_faxorder")!="Yes" && $oSystem->getValue("ecommerce_tr_personal")!="Yes" && $oSystem->getValue("ecommerce_tr_business")!="Yes"){
    echo"$opt_str<tr><td width=45%>&nbsp;</td><td width=20%><br><input type=text name=cquantity[] size=2 value=\"$myrow[1]\">&nbsp;</td><td><br>&nbsp;</td></tr>";
    } else {
    if ($prod_price>0){ echo"<tr><td colspan=3 valign=top>".$lang['eccatalog']['theprice']."&nbsp;:&nbsp;$currency_symbol_left $prod_price $currency_symbol_right &nbsp;</td></tr>"; }
    echo"$opt_str";
    if ($vprice>0){ echo"<tr><td width=45%><br>".$lang['eccatalog']['amount']."&nbsp;:&nbsp;$currency_symbol_left $vprice $currency_symbol_right &nbsp;&nbsp;x</td><td width=20%><br><input type=text name=cquantity[] size=2 value=\"$myrow[1]\">&nbsp;</td><td><br>=&nbsp; $currency_symbol_left $amount $currency_symbol_right &nbsp;</td></tr>";
    } else { echo"<tr><td width=45%>&nbsp;</td><td width=20%><br><input type=text name=cquantity[] size=2 value=\"$myrow[1]\">&nbsp;</td><td><br>&nbsp;</td></tr>"; }
    }

    echo"
    </table>
    </td>
    <td></td>
    <td width=20% valign=top align=right><input type=button value=\"".$lang['eccatalog']['removeitem']."\" onclick=\"document.frmCart.item_position.value='$position';document.frmCart.pageaction.value='removecart';document.frmCart.submit();\"></td>
    </tr>
    </table><br><hr size=1 color=#000000 width=98%>
    </td>
    </tr>
    ";
    $position++;
    } mysql_free_result($result);

    $total = CurrencyFormat($total);

    /*** calculate coupon apply here***/
    if($_COOKIE["cookie_couponid"]!="" && $_COOKIE["cookie_couponid"]!="empty"){
    $discount_id=$_COOKIE["cookie_couponid"];
    $ordertotal=$oDiscount->calculateDiscount($discount_id,$total);
    }
    /*** end of coupon ***/

    echo "
    </table>
    ";

    /*** RFQ Only ***/
    if ($oSystem->getValue("ecommerce_tr_rfqenable")=="Yes" && $oSystem->getValue("ecommerce_tr_ccenable")!="Yes" && $oSystem->getValue("ecommerce_tr_poenable")!="Yes" && $oSystem->getValue("ecommerce_tr_cheque")!="Yes" && $oSystem->getValue("ecommerce_tr_wiretransfer")!="Yes" && $oSystem->getValue("ecommerce_tr_moneyorder")!="Yes" && $oSystem->getValue("ecommerce_tr_offlinecc")!="Yes" && $oSystem->getValue("ecommerce_tr_cod")!="Yes" && $oSystem->getValue("ecommerce_tr_phoneorder")!="Yes" && $oSystem->getValue("ecommerce_tr_faxorder")!="Yes" && $oSystem->getValue("ecommerce_tr_personal")!="Yes" && $oSystem->getValue("ecommerce_tr_business")!="Yes"){
    } else {
    echo"<table border=0 width=98% align=center>";
    if($ordertotal!=""){
    if($val_discount>0){
    echo"
    <tr><td align=right colspan=5><b>".$lang['eccatalog']['total']." &nbsp;:&nbsp; $currency_symbol_left $total $currency_symbol_right</b></td><td align=center></td></tr>
    <tr><td align=right colspan=5><b>".$lang['eccatalog']['discount']." &nbsp;:&nbsp; $currency_symbol_left $val_discount $currency_symbol_right</b></td><td align=center></td></tr>
    <tr><td colspan=5><hr align=right size=1 color=#000000 width=28%></td></tr>
    ";
    }
    if($ordertotal>0){ echo"<tr><td align=right colspan=5><b>".$lang['eccatalog']['ordertotal']." &nbsp;:&nbsp; $currency_symbol_left $ordertotal $currency_symbol_right</b></td><td align=center></td></tr>"; }
    } else {
    if($total>0){ echo"<tr><td align=right colspan=5><b>".$lang['eccatalog']['ordertotal']." &nbsp;:&nbsp; $currency_symbol_left $total $currency_symbol_right</b></td><td align=center></td></tr>"; }
    }
    echo"</table><br>";
    }

    /*** RFQ Only ***/
    if ($oSystem->getValue("ecommerce_tr_rfqenable")=="Yes" && $oSystem->getValue("ecommerce_tr_ccenable")!="Yes" && $oSystem->getValue("ecommerce_tr_poenable")!="Yes" && $oSystem->getValue("ecommerce_tr_cheque")!="Yes" && $oSystem->getValue("ecommerce_tr_wiretransfer")!="Yes" && $oSystem->getValue("ecommerce_tr_moneyorder")!="Yes" && $oSystem->getValue("ecommerce_tr_offlinecc")!="Yes" && $oSystem->getValue("ecommerce_tr_cod")!="Yes" && $oSystem->getValue("ecommerce_tr_phoneorder")!="Yes" && $oSystem->getValue("ecommerce_tr_faxorder")!="Yes" && $oSystem->getValue("ecommerce_tr_personal")!="Yes" && $oSystem->getValue("ecommerce_tr_business")!="Yes"){
    } else {
    /*** enable discount apply here ***/
    if ($oSystem->getValue("ecommerce_ca_enablediscount")=="Yes"){
    /*** input coupon apply here ***/
    echo "
    <hr size=1 color=#000000 width=98%>
    <table border=0 cellspacing=1 cellpadding=1 width=98% align=center>
    <tr><td colspan=2><b>".$lang['eccatalog']['discountcoupon']."<b></td></tr>
    ";

    if ($_COOKIE["cookie_couponid"]!="" && $_COOKIE["cookie_couponid"]!="empty" && $detect_coupon!="Yes"){
    echo"<tr><td colspan=2><br><font color=\"ff0000\">".$lang['eccatalog']['invalidcoupon']."</font></td></tr>";
    }

    echo"
    <tr><td colspan=2><br>".$lang['eccatalog']['discountcoupontips']."</td></tr>
    <tr><td width=21%>".$lang['eccatalog']['counponcode']."</td><td><input type=text name=coupon_code style=\"width:150px\"><br></td></tr>
    <tr><td colspan=2>&nbsp;</td></tr>
    </table>
    ";
    }
    }

    echo"
    <table border=0 cellspacing=1 cellpadding=1 width=98% align=center>
    <tr><td width=15%><input type=\"button\" value=\"".$lang['eccatalog']['updatecart']."\" onclick=\"document.frmCart.pageaction.value='updatecart'; document.frmCart.submit();\"></td>
    <td width=15%><input type=\"button\" value=\"".$lang['eccatalog']['emptycart']."\" onclick=\"document.frmCart.pageaction.value='emptycart'; document.frmCart.submit();\"></td>
    <td width=20%><input type=\"button\" value=\"".$lang['eccatalog']['continueshopping']."\" onclick=\"window.location='".$thisfile."'\"></td>
    <td width=20% align=right><input type=\"button\" value=\"".$lang['eccatalog']['checkout']."\" onclick=\"window.location='".$thisfile."?homeinclude=transact'\"></td>
    </tr><tr><td colspan=4><br>&nbsp;</td></tr></form></table>
    ";
    } else {
    echo"<table border=0 width=98% align=center><tr><td align=center><b>".$lang['eccatalog']['yourshoppingcartempty']."</b></td></tr></table><br>";
    }

    }

    /***** Empty Shopping Cart *****/
    if($pageaction=="emptycart"){
    $oCatalog_Cart->delete($_COOKIE["cookie_cartid"]);
    echo "
    <script language=javascript src=\"".$path["webroot"]."common/lib.jsfunction.php\"></script>
    <script language=javascript>setCookie(\"cookie_cartid\", \"empty\")</script>
    <script language=javascript>setCookie(\"cookie_couponid\", \"empty\")</script>
    <script language=javascript>setCookie(\"cookie_tranmethod\", \"empty\")</script>
    <script language=javascript>setCookie(\"cookie_shipping\", \"empty\")</script>
    <script language=javascript>window.location='".$thisfile."?homeinclude=$homeinclude&pageaction=viewcart'</script>
    ";
    }

    ?>

    <script language=javascript>
    function CheckMinQuantity(minquantity){
    if(document.frmCart.val_qty.value<minquantity){
    <?$messageminquantity=$lang['eccatalog']['messageminquantity'];echo"alert(\"$messageminquantity\");";?>
    document.frmCart.val_qty.focus();
    return false;
    }else {
    return true;
    }
    }
    </script>
     
    Superior, May 30, 2007 IP
  6. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #6
    A few lines back from the last line:
    <?$message...
    PHP:
    change to:
    <?php
    $message...
    PHP:
    I do not know why someone is so desperate to save a few bytes in server side scripts... anyway, you can not take out the whitespace between a PHP opening tag and code after it.
     
    krt, May 30, 2007 IP
  7. HuggyCT2

    HuggyCT2 Guest

    Messages:
    222
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Its this bit I think,

    <?
    $messageminquantity=$lang['eccatalog']['messageminquantity'];echo"alert(\"$messageminquantity\");";
    ?>
    PHP:
    Its 8th from bottom line down.

    Change it to:

    
    <?
    $messageminquantity=$lang['eccatalog']['messageminquantity'];echo"alert(\'$messageminquantity\');";
    ?>
    PHP:
     
    HuggyCT2, May 30, 2007 IP
  8. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #8
    The quotation marks (") are escaped so there is no reason to switch them to single quotation marks.
     
    krt, May 30, 2007 IP
  9. Superior

    Superior Well-Known Member

    Messages:
    488
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #9
    Thanks both of you.
    i have tried as you told but the error is same. just it changes the line no. which is 1523 after adding space between tag.

    now error is
    Parse error: parse error, unexpected $ in
    /ecommerce/home.catalog.php on line 1523

    almost same error.
    thanks again all of you for you help. please guide me what i have to do now.
     
    Superior, May 30, 2007 IP
  10. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #10
    I made a mistake... when using short tags, there does not have to be a space between opening tag and code.

    Turns out "$" in this case is referring to the "end of line". PHP thinks that your code is not complete... there may be an if statement or something that does not have a closing bracket. If you don't know how to fix, perhaps post the whole code?
     
    krt, May 30, 2007 IP
  11. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #11
    Make a copy of the file in the directory it is in, and change the extension to .txt instead of .php and post a link to the whole script.
     
    krakjoe, May 30, 2007 IP
  12. Superior

    Superior Well-Known Member

    Messages:
    488
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #12
    Superior, May 30, 2007 IP
  13. Superior

    Superior Well-Known Member

    Messages:
    488
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #13
    waiting for any response from all members.
    please help me to solve this problem.
    Thanks
     
    Superior, May 31, 2007 IP
  14. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #14
    I admit this simple issue has baffled me, the supplied code seems fine and despite its length, I don't think I missed anything. Decided to google a little and found this:
     
    krt, May 31, 2007 IP