/    Sign up×
Community /Pin to ProfileBookmark

Strange parse error, unexpected ‘{‘

Hey guys,

I have this parse error:
[b]Parse error: parse error, unexpected ‘{‘ in /srv/www/htdocs/pages/mail.php on line 12[/b]

for the following code:

[code]
<?php

$name = $_POST[‘name’];
$from = $_POST[’email’];
$contact = $_POST[‘contact’];
$message = $_POST[‘message’];

if ($name == “” || $from == “” || $message == “”) {
print “<script type=”text/javascript”>alert(“You must fill out all fields!”);location.href = “javascript:history.go(-1)”;</script>”;
} else {

[color=red][b]12 =>[/color][/b] if (!eregi(“^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$”,$email) {
print “<script type=”text/javascript”>alert(“Please enter a valid email address!”);location.href = “javascript:history.go(-1)”;</script>”;
} else {

switch ( $contact )
{
case general :
$to=”[email protected]”;
break;
case sales :
$to=”[email protected]”;
break;
case services :
$to=”[email protected]”;
default :
$to=”an error occurred”;
break;
}

$subject = ‘Email from ‘.$name.”;
$headers = ‘From: ‘.$from.” . “rn” .
‘Reply-To: ‘.$from.” . “rn” .
‘X-Mailer: PHP/’ . phpversion();

mail($to, $subject, $message, $headers);

print ‘<p style=”text-align: center; “>Your message was sent successfully</p>’;
print ‘<p style=”text-align: center; “>Thank you for using our contact page.</p>’;
print ‘<p style=”text-align: center; font-size: 10pt; “>Going back to contact page (or click <a href=”javascript:history.go(-1)”>here</a>)</p>’;
print ‘<META HTTP-EQUIV=”Refresh” CONTENT=”3; URL=javascript:history.go(-1)”>’;
}
}

?>[/code]

I don’t understand why. Maybe I just can’t see the error… can anyone else?

hamstar

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 04.2005 — You need one more closing paren at the end of that line (just before the "{") to close the entire if() clause.
Copy linkTweet thisAlerts:
@hamstarauthorOct 04.2005 — oh i see... thank you...
×

Success!

Help @hamstar spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...