Forum Moderators: coopster
Parse error: parse error, unexpected $ in /home/httpd/vhosts/example.com/httpdocs/contactmail.php on line 49
Here's my script:
<?php
function checkOK($field)
{
if (eregi("\r",$field) ¦¦ eregi("\n",$field)){
die("Invalid Input!");
}
}
$name=$_POST['name'];
checkOK($name);
$email=$_POST['email'];
checkOK($email);
$street1=$_POST['street1'];
checkOK($street1);
$city=$_POST['city'];
checkOK($city);
$state=$_POST['state'];
checkOK($state);
$zip=$_POST['zip'];
checkOK($zip);
$daytime=$_POST['daytime'];
checkOK($daytime);
$home=$_POST['home'];
checkOK($home);
$contactmethod=$_POST['contactmethod'];
checkOK($contactmethod);
$questions=$_POST['questions'];
checkOK($questions);
//change conatact person's email here -
$to="kiki@fiestahomesnm.com";
$bodycopy="Hi Alan,\n\n I just visited your website and I had the following questons/comments for you:\n$questions \n\n
I prefer to be reached by $contactmethod and can be contacted at:\n
$email\n
$daytime# (daytime phone) or $home# (home or cell)\nPostal mail:\n
$street1\n$city, $state $zip\n\nThanks,\n$name;
if(mail($to,'Website Question',$bodycopy,'From: $email'))
{
echo 'Thank you for your email. Someone will be contacting you shortly.';
}
else {
echo 'There was a problem sending the mail. Please check that you filled in the form correctly.';
}
?>
Line 49 is:
?>
How am I getting an unexpected variable error for something that's a standard closing tag? HELP!
[edited by: coopster at 8:14 pm (utc) on Oct. 5, 2005]
[edit reason] generalized url in vhost dir error [/edit]
you get those errors usually with missing semi-colons, missing braces, missing parentheses and, as in this case, mismatched quotes
this causes any given line to carry on, encompassing many other lines and the parse error occurs much later in the script
this line
$street1\n$city, $state $zip\n\nThanks,\n$name;
is missing the closing quote, it should be
$street1\n$city, $state $zip\n\nThanks,\n$name";
;)