Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,245 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,245 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.