Web Hosting Talk







View Full Version : Parse error: parse error, unexpected T_STRING


NickMahon
12-08-2002, 02:10 PM
Hi,

Why does the following code return this error [Parse error: parse error, unexpected T_STRING in /home/virtual/site58/fst/var/www/html/inquire.php on line 142]?

It is driving me insane.


<html>
<head>
<title>Inquire</title>
</head>
<body>
<?

if(isset($Submit)){

if($iscustomer=="yes"){
$value[iscustomeryes] = " checked";
}
if($iscustomer=="no"){
$value[iscustomerno] = " checked";
}
if($isemerg=="yes"){
$value[isemergyes] = " checked";
}
if($isemerg=="no"){
$value[isemergno] = " checked";
}

$value[name] = " value=\"$_POST[name]\"";
$value[phone] = " value=\"$_POST[phone]\"";
$value[email] = " value=\"$_POST[email]\"";
$value[ordernum] = " value=\"$_POST[ordernum]\"";
$value[howdidyouhear] = " value=\"$_POST[howdidyouhear]\"";
$value[specifics] = $_POST[specifics];

}

$isvalid = 0;

if(isset($_POST[Submit])){

if(!$_POST[iscustomer]){

$isvalid = 0;
$error = "You must tell us if you are a current customer.";

} elseif ($_POST[iscustomer]=="yes"){

if(!$_POST[name]||!$_POST[phone]||!$_POST[email]||!$_POST[ordernum]||!$_POST[howdidyouhear]||!$_POST[isemerg]||!$_POST[specifics]||!$_POST[department]){

$isvalid = 0;
$error = "You must fill out all of the fields in the form.";

} else {

$isvalid = 1;

}

} elseif ($_POST[iscustomer]=="no"){

if(!$_POST[name]||!$_POST[email]||!$_POST[howdidyouhear]||!$_POST[specifics]||!$_POST[department]){

$isvalid = 0;
$error = "You must fill out your name, e-mail, how you heard about us, the specifics, and select a department.";

} else {

$isvalid = 1;

}

}

}

if($isvalid==0){

echo("<strong>$error</strong><br><br>");

?>
<form method="post" action="inquire.php">
<p><strong>Are you a current customer of ours?</strong><br>
<input type="radio" name="iscustomer" value="yes"<?=$value[iscustomeryes]?>>
Yes
<input type="radio" name="iscustomer" value="no"<?=$value[iscustomerno]?>>
No</p>
<p><strong>Your Name:
<input name="name" type="text" id="name"<?=$value[name]?>>
<br>
Phone
Number:</strong> <strong>
<input name="phone" type="text" id="phone"<?=$value[phone]?>>
</strong><br>
<strong>E-Mail Address:
<input name="email" type="text" id="email"<?=$value[email]?>>
</strong><br>
<strong>Order Number:
<input name="ordernum" type="text" id="ordernum" value="<?

if(isset($value[ordernum])) {
echo("$value[ordernum]");
} else {
echo("TSOLS-");
}

?>">
</strong><br>
If you have forgotten your order number, simply enter TSOLS-00000<br>
<strong>How did you hear about us?
<input name="howdidyouhear" type="text" id="howdidyouhear" size="50"<?=$value[howdidyouhear]?>>
</strong></p>
<p><strong>Is this an emergency?</strong><br>
<input type="radio" name="isemerg" value="yes"<?=$value[isemergyes]?>>
Yes
<input type="radio" name="isemerg" value="no"<?=$value[isemergno]?>>
No<br>
(Abuse of this feature will result in deletion of your message)</p>
<p><strong>Specifics:<br>
<textarea name="specifics" cols="70" rows="10" wrap="VIRTUAL" id="specifics"><?=$value[specifics]?></textarea>
</strong></p>
<p><strong>Please select a department to forward this request to:<br>
<select name="department" id="department">
<option>Select One...</option>
<option value="Order Status Request">Order Status Request</option>
<option value="Customer Service">Customer Service</option>
<option value="Vendor Inquries">Vendor Inquries</option>
<option value="Marketing Inquries">Marketing Inquries</option>
</select>
</strong></p>
<p><strong>
<input type="submit" name="Submit" value="Submit">
</strong></p>
</form>

<?

} elseif($isvalid==1){

if($_POST[isemerg]=="yes"){
$emerg = "[Emergency] ";
}

$other = "Your Company: ";
$other2 = "$_POST[department];

$subject = $emerg.$other.$other2;
$message = "This is an automatically-generated e-mail.".
"Past customer? ".$_POST[iscustomer]."".
"Name: ".$_POST[name]."".
"E-Mail: ".$_POST[email]."".
"Phone Number: ".$_POST[phone]."".
"Order Number: ".$_POST[ordernum]."".
"How they heard:".
$_POST[howdidyouhear].
$_POST[specifics];

mail("service@blah.com", $subject, $message, "From: ".$_POST[email]");

}

?>
</body>
</html>

ChickenSteak
12-08-2002, 03:23 PM
} elseif($isvalid==1){

if($_POST[isemerg]=="yes"){
$emerg = "[Emergency] ";
}

$other = "Your Company: ";
$other2 = "$_POST[department];

$subject = $emerg.$other.$other2;
$message = "This is an automatically-generated e-mail.";
"Past customer? ".$_POST[iscustomer]."".
"Name: ".$_POST[name]."".
"E-Mail: ".$_POST[email]."".
"Phone Number: ".$_POST[phone]."".
"Order Number: ".$_POST[ordernum]."".
"How they heard:".
$_POST[howdidyouhear].
$_POST[specifics];

mail("service@blah.com", $subject, $message, "From: ".$_POST[email]");

} What exactly are you trying to do with that little bit?

ChickenSteak
12-08-2002, 03:30 PM
$other2 = "$_POST[department]; Right there is the 142 line error that line should look like this: $other2 = "$_POST[department]"; Notice you missed the quotation for the end. Then there is an error on line 153 it has something to do with the mail(); function.

NickMahon
12-08-2002, 03:30 PM
That part generates the subject and message of the email and sends the form information to the administrator.

if($_POST[isemerg]=="yes"){
$emerg = "[Emergency] ";
}

$other = "Your Company: ";
$other2 = "$_POST[department];

$subject = $emerg.$other.$other2;

That is like that because I was bending over backwards trying to figure out why this isn't working.

Nick

NickMahon
12-08-2002, 03:32 PM
Fixed that, now I'm getting

Parse error: parse error, unexpected '\"' in /home/virtual/site58/fst/var/www/html/inquire.php on line 152

ChickenSteak
12-08-2002, 03:35 PM
Yea that has something to do with the way your combining everything in the mail() function, and I was a line off because very top there was space :D.

Give me the format you want the email to look like when its sent to you ie:

Firstname: blah
Lastname: blah
and so on.

ChickenSteak
12-08-2002, 03:38 PM
Heres line 152 error: mail("service@blah.com", $subject, $message, "From: ".$_POST[email]"); should look like this(the way your're doing it):mail("service@blah.com", $subject, $message, "From: ".$_POST[email]."); Although I would do it like this: mail("service@blah.com", $subject, $message, "From: {$_POST[email]}"); As the way you did it brings *another* error.

ChickenSteak
12-08-2002, 03:39 PM
PS here's the link: http://www.devnine.com/projects/nick :D.

NickMahon
12-08-2002, 03:54 PM
Thanks ;)

ChickenSteak
12-08-2002, 03:56 PM
No problem, if you run into anymore errors let me know ;):).