Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Build a Simple PHP Application - Getting an Error on Working with Get Variables

Hi guys!

I'm getting this error on both Firefox and IE during the Working with Get Variables section of the tutorials. It seems to be in the conditional statement, but I can't work out what's wrong.

"Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\contact.php on line 28"

Help would be much appreciated! Here's the PHP code for lines 28, 29 & 30...

<?php  if (isset($_GET["status"]) AND ($_GET["status"] == "thanks") { ?>
            <p>Thanks for the email! I'll be in touch shortly.</p>
        <?php } else { ?>

You have an extra ) in line 28. it should

AND $_GET["status"] == "thanks")

i.e. :

<?php  if (isset($_GET["status"]) AND $_GET["status"] == "thanks") { ?>
<p>Thanks for the email! I'll be in touch shortly.</p>
<?php } else { ?>

Thanks a million, Elizabeth! I clearly need to revise conditionals. Thanks so much for your help :)

1 Answer

I would be something along the lines of

<?php  if (isset($_GET["status"]) AND ($_GET["status"] === "thanks")) 
    {
    echo "<p>Thanks for the email! I'll be in touch shortly.</p>";
    }
    else {} ?>

Although it is the missing ) causing the main problem.

G