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 Basic PHP Website (2018) Adding a Basic Form Checking the Request Method

Parse error: syntax error, unexpected '{' in /home/treehouse/workspace/suggest.php on line 28

I seem to be getting an error after completing the steps taken in this video, I've double-checked with the video and my code is identical. (Albeit obviously not, as otherwise it would work! Haha)

Can anyone give me a hand with my code and tell me what's wrong with my IF statement? I'd really like to move on with the next part of the course.


include("inc/header.php"); ?> <div class="section page"> <div class="wrapper"> <h1>Suggest a Media Item</h1> <?php if (isset($_GET["status"] && $_GET["status"] == "thanks") { echo "<p>Thanks for the email! I’ll check out your suggestion shortly!</p>"; } else { ?> <p>If you think there is something I’m missing, let me know!</p> <form method="post" action="suggest.php"> <table> <tr> <th><label for="name">Name:</label></th> <td><input type="text" id="name" name="name" /></td> </tr>

          <th><label for="email">Email:</label></th>
          <td><input type="text" id="email" name="email" /></td>
          <th><label for="details">Details:</label></th>
          <td><input type="textarea" id="details" name="details" /></td>
      <input type="submit" value="Send" />      
  <?php } ?>

</div> </div> <?php include("inc/footer.php"); ?> '''

4 Answers

Joel Bardsley
Joel Bardsley
31,246 Points
<?php if (isset($_GET["status"] && $_GET["status"] == "thanks") {

You've closed the if statement parentheses, but not the isset ones.

I'm unsure as to why my code didn't post correctly when I used the back tick format? Could someone edit it and correct it for me and tell me what I've done wrong? Cheers!

Hi Joe,

If I change the code to this and add a closing parentheses for the issset:

<?php if (isset($_GET["status"] && $_GET["status"] == "thanks")) {

It gives me a different error:

Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in /home/treehouse/workspace/suggest.php on line 28

Kind regards,

Joel Bardsley
Joel Bardsley
31,246 Points

You've closed it in the wrong place:

<?php if (isset($_GET["status"]) && $_GET["status"] == "thanks") {

Cheers Joel! All sorted.

Need to fix up my closing skills.