/    Sign up×
Community /Pin to ProfileBookmark

unexpected $end in????

I am simply pulling this code from an existing PHP script, but now I am getting an unexpected $end in the file line 40. Any ideas on where I am messing up on this? The close tag looks fine to me.

[code=php]<?php
if(trim($_POST[‘name’]) == “”) {
die(“You did not enter a name”);
}
if(trim($_POST[’email’]) == “”) {
die(“You did not enter an email”);

$con = mysql_connect(“database”,”name”,”pass”);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
mysql_select_db(“database”, $con);
$sql=”INSERT INTO Table (Name, Email, Date)
VALUES
(‘$_POST[name]’,’$_POST[email]’,’$_POST[Date]’)”;

if (!mysql_query($sql,$con))
{
die(‘Error: ‘ . mysql_error());
}

echo “”;

$subject = ‘subject’;
$message = ‘message ‘;

$header = “From: Independent Retail Week: NYC”;

mail($_POST[’email’],$subject,$message,$header);

mysql_close($con)
?>[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@scragarOct 22.2008 — <i>
</i>...
if(trim($_POST['email']) == "") {
die("You did not enter an email");
[b]}[/b]
...


add the missing closing brace.
Copy linkTweet thisAlerts:
@skywalker2208Oct 22.2008 — you are missing a semi-colon on the mysql_close function.
Copy linkTweet thisAlerts:
@scragarOct 22.2008 — you are missing a semi-colon on the mysql_close function.[/QUOTE]

that last one isn't necessary as long as there is no PHP code after that point you can leave it off(I wouldn't incase you add stuff after it later, but you can if you so wanted), the problem is with PHP seeing the end of the page as still being inside the if condition like I said.
Copy linkTweet thisAlerts:
@ShortsOct 22.2008 — Indeed scragar is correct, $end pretty much means a missing curly bracket.

Which sometimes can be one of the more annoying errors if you have a lot of conditionsclassesfunctions...
×

Success!

Help @1234567890 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.17,
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,
)...