...

View Full Version : Help with syntax error, unexpected T_VARIABLE



p@p
05-24-2011, 07:39 PM
I'm a bit confused this is a first time for me to write the some of forms used many field and i got an error with syntax error, unexpected T_VARIABLE with line 52.

This filename is contact.php


<table style="width: 100%" cellpadding="1" cellspacing="3">
<form enctype="multipart/form-data" onSubmit="return validate_form(this)" action="mailer.php" method="post" name="odr_frm" id="odr_frm">
<tr>
<td colspan="3" class="HeadOrd">&nbsp;&nbsp;Data Account</td>
</tr>
<tr class="isiorder">
<td align="left" style="width: 5px">*</td>
<td align="left">E-Currency</td>
<td align="left">
<select name="currencynya" id="currencynya" onChange="odr_frm.n_tukar.value = this.options[this.selectedIndex].value; odr_frm.ecurna.value = this.options[this.selectedIndex].text">
<option value="0">Please Choose</option>
<option value="<?php
$sqlTampil = "SELECT * FROM paypal ORDER BY id";
$qryTampil = mysql_query($sqlTampil, $koneksi)
or die ("Gagal query".mysql_error());

while($dataTampil=mysql_fetch_array($qryTampil)) {
?><?php echo "$dataTampil[beli]"; ?><?php } ?>">PayPal</option>
</select>&nbsp;
</td>
</tr>
<tr>
<td align="left" style="width: 5px">*</td>
<td align="left" class="isiorder">PayPal Email</td>
<td align="left"><input name="no_account" type="text" id="no_account">&nbsp;</td>
</tr>
<tr>
<td align="left" style="width: 5px">*</td>
<td align="left">Nama Di Account </td>
<td align="left"><input name="nama_diacc" type="text" id="nama_diacc"></td>
</tr>
<tr class="isiorder">
<td align="left" style="width: 5px">*</td>
<td align="left">Jumlah Beli (USD)</td>
<td align="left">$ <input name="jml_beli" id="jml_beli" value="0" maxlength="6" type="text" onKeyUp="javascript: odr_frm.jmltrfs.value=odr_frm.jml_beli.value*odr_frm.n_tukar.value; odr_frm.dlmbilangan.value = terbilang(odr_frm.jml_beli.value*odr_frm.n_tukar.value)" style="width: 100px">&nbsp; x&nbsp; <input name="n_tukar" id="n_tukar" type="text" size="6" maxlength="6" readonly="1"/></td>
</tr>
<tr class="isiorder">
<td style="width: 5px">&nbsp;</td>
<td align="left">Nilai Transfer (IDR)</td>
<td align="left">Rp <input name="jmltrfs" id="jmltrfs" value="0" type="text" readonly="1"></td>
</tr>
<tr class="isiorder">
<td style="width: 5px">&nbsp;</td>
<td align="left" valign="top">Terbilang</td>
<td align="left"><textarea readonly name="dlmbilangan" id="dlmbilangan" style="height: 71px; width: 235px"></textarea>&nbsp;</td>
</tr>
<tr class="isiorder">
<td style="width: 5px">&nbsp;</td>
<td align="left">Keterangan</td>
<td align="left"><input name="ket" id="ket" type="text" style="width: 235px"></td>
</tr>
<tr class="lrnya">
<td colspan="3" class="HeadOrd">&nbsp;&nbsp;Data Bank</td>
</tr>
<tr>
<td align="left" style="width: 5px">*</td>
<td align="left">Bank</td>
<td align="left"><select name="banknya" id="banknya">
<option value="Please Choose">Please Choose</option>
<option value="BCA">BCA</option>
<option value="MANDIRI">MANDIRI</option>

</select>&nbsp;</td>
</tr>
<tr>
<td align="left" style="width: 5px">*</td>
<td align="left">No Rekening</td>
<td align="left"><input name="no_rek" id="no_rek" type="text"> masukkan tanpa tanda baca</td>
</tr>
<tr>
<td align="left" style="width: 5px">*</td>
<td align="left">Nama Di Rekening</td>
<td align="left"><input name="nama_rek" id="nama_rek" type="text"></td>
</tr>
<tr>
<td colspan="3" class="HeadOrd">&nbsp;&nbsp;Data Pribadi</td>
</tr>
<tr>
<td align="left" style="width: 5px">*</td>
<td align="left">Nama Lengkap</td>
<td align="left"><input name="vnama" id="vnama" type="text" style="width: 235px"></td>
</tr>
<tr>
<td align="left" style="width: 5px">*</td>
<td align="left">Email</td>
<td align="left"><input name="vemail" id="vemail" type="text" style="width: 235px"></td>
</tr>
<tr>
<td style="width: 5px">&nbsp;</td>
<td align="left">Instant Mesengger</td>
<td align="left"><input name="vIm" id="vIm" type="text" style="width: 235px"></td>
</tr>
<tr>
<td style="width: 5px">&nbsp;</td>
<td align="left">Alamat Lengkap</td>
<td align="left"><input name="vkota" id="vkota" type="text" style="width: 235px"></td>
</tr>
<tr>
<td align="left" style="width: 5px">*</td>
<td align="left">No Hp</td>
<td align="left"><input name="vhp" id="vhp" type="text" style="width: 235px"></td>
</tr>
<tr>
<td align="left" style="width: 5px">*</td>
<td align="left">Type verification image:</td>
<td align="left"><img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="absbottom" /><br />
<input name="verif_box" type="text" id="verif_box" style="padding:2px; border:1px solid #CCCCCC; width:100px; height:14px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;"/>
</td>
</tr>
<tr>
<td style="width: 5px">&nbsp;</td>
<td>&nbsp;</td>
<td><input name="ecurna" type="hidden">
<input id="data_odr_frm" name="data_odr_frm" type="hidden" value="odr_frm" /><br/><input type="image" src="img/order.gif">
</td>
</tr>
</form>
</table>


And this filename is mailer.php

<?php
// remember to replace you@email.com with your own email address lower in this code.

// load the variables form address bar
$currencynya = $_POST["currencynya"];
$no_account = $_POST["no_account"];
$nama_diacc = $_POST["nama_diacc"];
$jml_beli = $_POST["jml_beli"];
$jmltrfs = $_POST["jmltrfs"];
$dlmbilangan = $_POST["dlmbilangan"];
$ket = $_POST["ket"];
$banknya = $_POST["banknya"];
$no_rek = $_POST["no_rek"];
$nama_rek = $_POST["nama_rek"];
$vnama = $_POST["vnama"];
$vemail = $_POST["vemail"];
$vIm = $_POST["vIm"];
$vkota = $_POST["vkota"];
$vhp = $_POST["vhp"];
$verif_box = $_POST["verif_box"];

// remove the backslashes that normally appears when entering " or '
$currencynya = stripslashes($currencynya);
$no_account = stripslashes($no_account);
$nama_diacc = stripslashes($nama_diacc);
$jml_beli = stripslashes($jml_beli);
$jmltrfs = stripslashes($jmltrfs);
$dlmbilangan = stripslashes($dlmbilangan);
$ket = stripslashes($ket);
$banknya = stripslashes($banknya);
$no_rek = stripslashes($no_rek);
$nama_rek = stripslashes($nama_rek);
$vnama = stripslashes($vnama);
$vemail = stripslashes($vemail);
$vIm = stripslashes($vIm);
$vkota = stripslashes($vkota);
$vhp = stripslashes($vhp);

// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if verification code was correct send the message and show this page
mail("mountainvibe@gmail.com", 'Indoexechanges.com Order Form: '$_SERVER['REMOTE_ADDR']."\n\n Currency:".$currencynya, "\n\n No Account".$no_account, "\n\n Nama Account:".$nama_diacc, "\n\n Jumlah Beli:".$jml_beli, "\n\n Jumlah Transfer:".$dlmbilangan, "\n\n Keterangan:".$ket, "\n\n Bank Transfer:".$no_rek, "\n\n Nama Di Rekening:".$nama_rek, "\n Nama Lengkap:".$vname, "\n\n Email:".$vemail, "\n\n Instant Messenger:".$vIm, "\n\n Alamat Lengkap:".$vkota, "\n\n HP:".$vhp, "From: $vnama");
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
} else if(isset($currencynya, $no_account, $nama_diacc, $jml_beli, $jmltrfs, $dlmbilangan, $ket, $banknya, $no_rek, $nama_rek, $vnama, $vemail, $vIm, $vkota, $vhp) and $currencynya, $no_account, $nama_diacc, $jml_beli, $jmltrfs, $dlmbilangan, $ket, $banknya, $no_rek, $nama_rek, $vnama, $vemail, $vIm, $vkota, $vhp!=""){
// if verification code was incorrect then return to contact page and show error
header("Location: contact.php?from=$vnama&from=$from&message=".urlencode($no_account)."&wrong_code=true");
exit;
} else {
echo "no variables received, this page cannot be accessed directly";
exit;
}
?>
<h1>Success</h1>

When i submit the button from the contact.php it's will action to mailer.php and i got an error with


Parse error: syntax error, unexpected T_VARIABLE in /home/test/public_html/mailer.php on line 52

Perhaps someone could help me to fix the script :(

tangoforce
05-24-2011, 07:45 PM
Look:
mail("mountainvibe@gmail.com", 'Indoexechanges.com Order Form: '$_

Shouldn't there be a . somewhere?- From: ' . $_

p@p
05-24-2011, 07:55 PM
Look:
mail("mountainvibe@gmail.com", 'Indoexechanges.com Order Form: '$_

Shouldn't there be a . somewhere?- From: ' . $_

When i added this in mailer.php on line 52


mail("mountainvibe@gmail.com", 'Indoexechanges.com Order Form: '.$_SERVER['REMOTE_ADDR']."\n\n Currency:".$currencynya, "\n\n No Account".$no_account, "\n\n Nama Account:".$nama_diacc, "\n\n Jumlah Beli:".$jml_beli, "\n\n Jumlah Transfer:".$dlmbilangan, "\n\n Keterangan:".$ket, "\n\n Bank Transfer:".$no_rek, "\n\n Nama Di Rekening:".$nama_rek, "\n Nama Lengkap:".$vname, "\n\n Email:".$vemail, "\n\n Instant Messenger:".$vIm, "\n\n Alamat Lengkap:".$vkota, "\n\n HP:".$vhp, "From: $vnama");
// delete the cookie so it cannot sent again by refreshing this page

I got another error: Parse error: syntax error, unexpected ',' in /home/indoex/public_html/mailer.php on line 55

On line 55 in mailer.php:

} else if(isset($currencynya, $no_account, $nama_diacc, $jml_beli, $jmltrfs, $dlmbilangan, $ket, $banknya, $no_rek, $nama_rek, $vnama, $vemail, $vIm, $vkota, $vhp) and $currencynya, $no_account, $nama_diacc, $jml_beli, $jmltrfs, $dlmbilangan, $ket, $banknya, $no_rek, $nama_rek, $vnama, $vemail, $vIm, $vkota, $vhp!=""){
// if verification code was incorrect then return to contact page and show error
header("Location: contact.php?from=$vnama&from=$from&message=".urlencode($no_account)."&wrong_code=true");
exit;
} else {
echo "no variables received, this page cannot be accessed directly";
exit;
}
?>


Could you help me? :(

tangoforce
05-24-2011, 08:09 PM
The php debugger can often be wrong about line numbers.

Please the entire revised code and also check out the link in my signature about coding styles.

p@p
05-24-2011, 08:12 PM
The php debugger can often be wrong about line numbers.

Please the entire revised code and also check out the link in my signature about coding styles.
I was edit on line 52 - 61


// if verification code was correct send the message and show this page
mail("mountainvibe@gmail.com", 'Indoexechanges.com Order Form: '.$vnama,$_SERVER['REMOTE_ADDR']."\n\n Currency:".$currencynya, "\n\n No Account".$no_account, "\n\n Nama Account:".$nama_diacc, "\n\n Jumlah Beli:".$jml_beli, "\n\n Jumlah Transfer:".$dlmbilangan, "\n\n Keterangan:".$ket, "\n\n Bank Transfer:".$no_rek, "\n\n Nama Di Rekening:".$nama_rek, "\n Nama Lengkap:".$vnama, "\n\n Email:".$vemail, "\n\n Instant Messenger:".$vIm, "\n\n Alamat Lengkap:".$vkota, "\n\n HP:".$vhp, "From: $vnama");
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
}
else if(isset($currencynya,$no_account,$nama_diacc,$jml_beli,$jmltrfs,$dlmbilangan,$ket,$banknya,$no_rek, $nama_rek,$vnama,$vemail,$vIm,$vkota,$vhp) and $currencynya,$no_account,$nama_diacc,$jml_beli,$jmltrfs,$dlmbilangan,$ket,$banknya,$no_rek,$nama_rek ,$vnama,$vemail,$vIm,$vkota,$vhp!=""){
// if verification code was incorrect then return to contact page and show error
header("Location: contact.php?from=$vnama&from=$no_account&message=".urlencode($no_account)."&wrong_code=true");
exit;
}


But still getting an error Parse error: syntax error, unexpected ',' in /home/test/public_html/mailer.php on line 57

tangoforce
05-24-2011, 08:26 PM
The internal one php uses to find these errors...

I don't know how many mail parameters you're trying to pass but you're trying to pass too many - look how many commas (,) you're using:


mail("mountainvibe@gmail.com",//Email address
'Indoexechanges.com Order Form: '//Subject
.$_SERVER['REMOTE_ADDR']."\n\n Currency:"//Subject (on a new line???)
.$currencynya, //Subject
"\n\n No Account".$no_account, //Message
"\n\n Nama Account:".$nama_diacc, //Additional Headers
"\n\n Jumlah Beli:".$jml_beli, //Additional Parameters
"\n\n Jumlah Transfer:".$dlmbilangan, //Doesn't exist
"\n\n Keterangan:".$ket, //Doesn't exist
"\n\n Bank Transfer:".$no_rek, //Doesn't exist
"\n\n Nama Di Rekening:".$nama_rek, //Doesn't exist
"\n Nama Lengkap:".$vname, //Doesn't exist
"\n\n Email:".$vemail, //Doesn't exist
"\n\n Instant Messenger:".$vIm, //Doesn't exist
"\n\n Alamat Lengkap:".$vkota, //Doesn't exist
"\n\n HP:".$vhp, //Doesn't exist
"From: $vnama");// Shouldn't this be a header?


This is the mail() function and parameter format from php.net:
mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

As you can see, there is a maximum of 5 parameters seperated by a ,

I've never seen this before:


and $currencynya, $no_account, $nama_diacc, $jml_beli, $jmltrfs, $dlmbilangan, $ket, $banknya, $no_rek, $nama_rek, $vnama, $vemail, $vIm, $vkota, $vhp!=""){


It can't be done. You have to check them all individually.


You can use 'and' between your variables instead of ,

p@p
05-24-2011, 08:53 PM
The internal one php uses to find these errors...

I don't know how many mail parameters you're trying to pass but you're trying to pass too many - look how many commas (,) you're using:


mail("mountainvibe@gmail.com",//Email address
'Indoexechanges.com Order Form: '//Subject
.$_SERVER['REMOTE_ADDR']."\n\n Currency:"//Subject (on a new line???)
.$currencynya, //Subject
"\n\n No Account".$no_account, //Message
"\n\n Nama Account:".$nama_diacc, //Additional Headers
"\n\n Jumlah Beli:".$jml_beli, //Additional Parameters
"\n\n Jumlah Transfer:".$dlmbilangan, //Doesn't exist
"\n\n Keterangan:".$ket, //Doesn't exist
"\n\n Bank Transfer:".$no_rek, //Doesn't exist
"\n\n Nama Di Rekening:".$nama_rek, //Doesn't exist
"\n Nama Lengkap:".$vname, //Doesn't exist
"\n\n Email:".$vemail, //Doesn't exist
"\n\n Instant Messenger:".$vIm, //Doesn't exist
"\n\n Alamat Lengkap:".$vkota, //Doesn't exist
"\n\n HP:".$vhp, //Doesn't exist
"From: $vnama");// Shouldn't this be a header?


This is the mail() function and parameter format from php.net:
mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

As you can see, there is a maximum of 5 parameters seperated by a ,

I've never seen this before:


and $currencynya, $no_account, $nama_diacc, $jml_beli, $jmltrfs, $dlmbilangan, $ket, $banknya, $no_rek, $nama_rek, $vnama, $vemail, $vIm, $vkota, $vhp!=""){


It can't be done. You have to check them all individually.


You can use 'and' between your variables instead of ,


When I'm edited on line 73 to:

else if(isset($currencynya, $no_account, $nama_diacc, $jml_beli, $jmltrfs, $dlmbilangan, $ket, $banknya, $no_rek, $nama_rek, $vnama, $vemail, $vIm, $vkota, $vhp) {
// if verification code was incorrect then return to contact page and show error
header("Location: contact.php?from=$vnama&from=$no_account&message=".urlencode($no_account)."&wrong_code=true");
exit;
}

It's still shown an error Parse error: syntax error, unexpected '{' in /home/test/public_html/mailer.php on line 73

tangoforce
05-24-2011, 09:22 PM
I've already pointed you to my topic about the $end errors and coding styles in post 4. You've ignored it and are now asking about a problem with a { ?

p@p
05-24-2011, 09:28 PM
Any help?? I'm not just asking to you. This forum is for public and I'm asking not just for you, I don't think so following your post 8 it will given the error. If that give an error then why I was looked some site used more than 5 variable it's possible? Huh??!!

tangoforce
05-24-2011, 09:36 PM
I've seen several websites which offer the wrong php advice which completely contradicts the php.net manual.

I have no idea what you're trying to say about 5 variables in post 8.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum