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.
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 : )
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%> </td><td width=20%><br><input type=text name=cquantity[] size=2 value=\"$myrow[1]\"> </td><td><br> </td></tr>"; } else { if ($prod_price>0){ echo"<tr><td colspan=3 valign=top>".$lang['eccatalog']['theprice']." : $currency_symbol_left $prod_price $currency_symbol_right </td></tr>"; } echo"$opt_str"; if ($vprice>0){ echo"<tr><td width=45%><br>".$lang['eccatalog']['amount']." : $currency_symbol_left $vprice $currency_symbol_right x</td><td width=20%><br><input type=text name=cquantity[] size=2 value=\"$myrow[1]\"> </td><td><br>= $currency_symbol_left $amount $currency_symbol_right </td></tr>"; } else { echo"<tr><td width=45%> </td><td width=20%><br><input type=text name=cquantity[] size=2 value=\"$myrow[1]\"> </td><td><br> </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']." : $currency_symbol_left $total $currency_symbol_right</b></td><td align=center></td></tr> <tr><td align=right colspan=5><b>".$lang['eccatalog']['discount']." : $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']." : $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']." : $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> </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> </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>
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.
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:
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.
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?
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.
Here is the complete code of the file http://www.mobilespoint.com/catalog.txt please check it out. Thanks
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: