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

Dermot Condron
Dermot Condron
4,010 Points

contact.php parse error

Hi there I have the following error on Shirts 4 Mike Contact.php

Parse error: syntax error, unexpected '{' in C:\wamp\www\shirts 4 mike\contact.php on line 32

Can anyone see the problem with this code? It follows the tutorial exactly.

Line 32 of my code is as follows:

<h1>Contact</h1>

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

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

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

// Then form ends with the following code </form> <?php } ?>

5 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Here is what I have for that PHP code block:

<?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 to 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> 
                        <tr style="display: none;">
                            <th>
                                <label for="address">Address</label>
                            </th>
                            <td>
                                <input type="text" name="address" id="address">
                                <p>Humans (and frogs): please leave this field blank.</p>
                            </td>
                        </tr>                   
                    </table>
                    <input type="submit" value="Send">

                </form>

            <?php } ?>

Again, double check that you have the same number of opening and closing brackets of the corresponding type. Missing one of them will produce the errors you seem to be experiencing.

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Looks like you have an extra ( before $_GET.

Count your opening and closing parenthesis, brackets, etc. to make sure you have the same number.

Dermot Condron
Dermot Condron
4,010 Points

Thanks for your reply. Tried removing that parenthesis but it created a new error. For some reason it doesn't like the opening curly brace of the if statement

Dermot Condron
Dermot Condron
4,010 Points

Thanks Ken! Removing the parenthesis after the AND and before the $_GET fixed the problem. Initially I was removing the parenthesis after the isset and just before the $_GET.

Thanks for your help! Dermot

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Sorry for the initial confusion as to which ( to remove.

Pleased it all worked out.