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


Katie Charles-McGrath
Katie Charles-McGrath
1,823 Points

Getting "Parse error: syntax error, unexpected ';' in /home/treehouse/workspace/suggest.php on line 3"

I know this is going to be something obvious, but I've compared my code to the download code and as far as I can tell, my code is exactly the same as Alena's.

  $name = $_POST["name"];
  $email = $_POST["email"];
  $details = $_POST["details"];

  echo "<pre>";
  $email_body = "";
  $email_body .= "Name " . $name . "\n";
  $email_body .= "Email " . $email . "\n";
  $email_body .= "Details " . $details . "\n";
  echo $email_body;
  echo "</pre>";

  //To Do: Send Email

$pageTitle = "Suggest a Media Item";
$section = "suggest";

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&rsquo;ll check out your suggestion shortly!</p>";
        } else {
        <p>If you think there is something I&rsquo;m missing, let me know! Complete the form to send me an email.</p>
        <form method="post" action="process.php">
                <th><label for="name">Name</label></th>
                <td><input type="text" id="name" name="name" /></td>
                <th><label for="email">Email</label></th>
                <td><input type="text" id="email" name="email" /></td>
                <th><label for="name">Suggest Item Details</label></th>
                <td><textarea name="details" id="details"></textarea></td>
            <input type="submit" value="Send" />
        <?php } ?>

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

Can anyone see something I don't?

Hi Katie,

Can you post a snapshot to your workspace? Right now I'm not seeing an issue.

Katie Charles-McGrath
Katie Charles-McGrath
1,823 Points

Here's a link to the snapshot (I think that's how this works):


The suggest.php file in question is the one now called kt_suggest.php. I renamed it and replaced it with the downloaded version so that I could move on with the course.

Thank you!

2 Answers

The code you posted in your question must have been the corrected code because it's different from what you have in kt_suggest.php

You have a misplaced bracket and missing parenthesis to close off the if condition in kt_suggest.php

Compare the following:

// from kt_suggest.php
// corrected code

I forked your workspace and made that change and your page seems to be displaying correctly.

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Hey Katie,

The code you have posted in the question here doesn't appear to have any syntax error; however, in your Workspace snapshot, the file kt_suggest.php does have a misplaced closing square bracket in the opening line of code.

It reads


but should read


The error will be thrown on the following line from where the actual error is (usually). It wasn't until the compiler got to the semi-colon on line three that it realized something wasn't right. It reached a statement end, but didn't have a valid statement.

The square brackets are pointing to an index in the array, so with the closing bracket after post, the compiler is looking for an index named "REQUEST METHOD" == "POST" instead of comparing the index value against "POST".

I hope this makes sense. Keep Coding! :dizzy: