/    Sign up×
Community /Pin to ProfileBookmark

unexpected T_ELSE wtf

I’m getting the following error in this code and am unaware of why the syntax error is being thrown. I’ve looked at the cause of the error and it doesn’t seem to make sense to me. Could any of you php super heroes take a look at this and tell me what I’m doing wrong?

The error is this.

[QUOTE]

Parse error: syntax error, unexpected T_ELSE in /var/www/multilang_feedback.php on line 12

[/QUOTE]

So this is the line it has a problem with.

[QUOTE]

else if(isset($_POST[‘lang’] ) )

[/QUOTE]

Thank you greatly for your time.

[code=php]<?php
//multilang_feedback.php starts 13:39 User Interacton
// demo of User Interaction in PHP

$me = $_SERVER[‘PHP_SELF’];

$choices = array(“en” => “English”, “fr” => “Francais”);
$comment_string = array(“en” => “Comments”, “fr” => “Commentaires”);
$submit_string = array(“en” => “Submit”, “fr” => “Soumettre”);
$return_string = array(“en” => “Return”, “fr” => “Retour”);

else if(isset($_POST[‘lang’] ) )
{
$lang – $_POST[‘lang’];

print(“<form action=”$me” method=”post”>n”);
print(“comment_string[$lang]:”);
print(“<input type=”hidden” name=”lang” value=”$lang”/><br>n”);
print(“<input type=”text” name=”comments” size=”60″/><br>n”);
print(“<input type=”submit” value=”$submit_string[$lang]”/><br>n”);
print(“</form>n”);
}
else
{
print(“<form action=”$me” method=”post”>n”);
print(“<select name=”lang”>n”);
foreach($choices as $c => $n)
{
print(“<option value=”$c”>$n</option>n”);
}
print(“</select>n”);
print(“<input type=”submit” value=”Select Language / Langue Preferee”/><br>n”) print(“</form>n”);
}

?>
[/code]

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@tracknutJun 03.2010 — Well, "else" is supposed to come after a prior "if". You can't just start in with "else... somethingorother", which is how you've done it.

Dave
Copy linkTweet thisAlerts:
@NogDogJun 03.2010 — Also, it may just be a copy-and-paste error, but that long line near the end of the code is missing a ";" after the first print() command (and I'm guessing you wanted the next print() to start a new line).
Copy linkTweet thisAlerts:
@ebrownauthorJun 03.2010 — I feel very dumb. Thank you for your time.
Copy linkTweet thisAlerts:
@tracknutJun 03.2010 — I feel very dumb.[/QUOTE]

No need, sometimes we've stared at the same piece of code for so long, it looks right no matter what's screwing about it!

Dave
Copy linkTweet thisAlerts:
@phoenixbytesJun 04.2010 — No need, sometimes we've stared at the same piece of code for so long, it looks right no matter what's screwing about it!

Dave[/QUOTE]


done that millions of times it's not even funny lol
Copy linkTweet thisAlerts:
@NogDogJun 04.2010 — done that millions of times it's not even funny lol[/QUOTE]

I just spent maybe 15 minutes trying to figure out why an HTML form was screwed up until I realized I'd spelled "colspan" as "cospan" and copied it into 3 other tags. :rolleyes: (Thanks to the W3C validator.)
×

Success!

Help @ebrown 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.20,
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,
)...