Forum Moderators: coopster

Message Too Old, No Replies

HELP! Parse error

Mail script, this can't be right...

         

kikithemorse

7:30 pm on Oct 5, 2005 (gmt 0)

10+ Year Member



I'm getting the following error when my server tries to process this script:

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]

jatar_k

7:35 pm on Oct 5, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld kikithemorse,

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";

;)

kikithemorse

7:51 pm on Oct 5, 2005 (gmt 0)

10+ Year Member



Sure enough, that fixed it. Thanks a bunch for your help!