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

General Discussion

Parse error: syntax error, unexpected end of file in

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\contact.php on line 75. What am I missing? I get the same error message at (http://phpcodechecker.com/).

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST")
{
    /*echo "I have information from a form. Now what?";
    var_dump($_POST);*/
    $name = $_POST["name"];
    $email = $_POST["email"];
    $message = $_POST["message"];
    $email_body = "";
    $email_body = $email_body . "Name: " . $name . "\n";
    $email_body = $email_body . "Email: " . $email . "\n";
    $email_body = $email_body . "Message: " . $message . "\n";
    echo $email_body;

    // TODO: Send Email

    header("Location: contact.php?status=thanks");
    exit;
}

?>
<?php

$pageTitle = "Contact Mike";
$section = "contact";
include 'inc/header.php'; ?>

<div class="section_page">

    <div class="wrapper">

        <h1>Contacts</h1>

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

            <p>I&rsquo;d love to hear from you! Complete the form and send me an email.</p>

            <form method="post" action="contact.php">

                <table>

                    <tr>
                        <th><label for="name">Name</label></th>
                        <td><input type="text" name="name" id="name"></td>
                    </tr>
                    <tr>
                        <th><label for="email">Email</label></th>
                        <td><input type="text" name="email" id="email"></td>
                    </tr>
                    <tr>
                        <th><label for="message">Message</label></th>
                        <td><textarea name="message" id="message"></textarea></td>
                    </tr>
                </table>

                <input type="submit" value="send">
            </form>
        }

    </div>

</div>

<?php
include 'inc/footer.php';
?>

2 Answers

The last closing brace for your if statement is outside of a php tag (the one right above the two closing div tags).

Thanks Ben,

All I had to do was this: "<?php } ?>". Mixing PHP and HTML gets a little confusing.

Jeff

Andrew Hartley
Andrew Hartley
2,750 Points

BEN! Answered nearly four years ago, and I was struggling with the same issue, exactly, but on a project of my own. Once I looked for a misplaced or missing }, problem solved. Unbelievable. You are my hero!