Why am I getting an "Unexpected $end" in my php code?
<p>I do not know what im doing wrong. I have been looking through other forums that say my problem might be related to not having closed curly braces closed or a short php tag <code>&lt;? ...</code>. I have none of these as far as I can tell. This is a form that lets you know if any fields are left blank.</p>

<pre><code>&lt;?php

if (count($_POST) &gt; 0)
{

    function check_if_field_submitted($field_to_check)
    {
        if (isset($_POST[$field_to_check]) &amp;&amp; $_POST[$field_to_check] != '')
        {
            return TRUE;
        }
        else
        {
            return "YOU MUST FILL IN THE $field_to_check FIELD!";
        }
    }

    //--------------------------------------------------------

    $error_messages = array();

    //Validate the input

    //Trim the fields
    $_POST['first_name'] = trim($_POST['first_name']);
    $_POST['last_name'] = trim($_POST['last_name']);
    $_POST['comments'] = trim($_POST['comments']);
    $_POST['first_name'] = strip_tags($_POST['first_name']);
    $_POST['last_name'] = strip_tags($_POST['last_name']);
    $_POST['comments'] = strip_tags($_POST['comments']);

    //Required fields:

    if (check_if_field_submitted('first_name') !== TRUE)
    {
        $error_messages[] = check_if_field_submitted('first_name');
    }

    if (check_if_field_submitted('last_name') !== TRUE)
    {
        $error_messages[] = check_if_field_submitted('last_name');    
    }

    if (check_if_field_submitted('hobbies') !== TRUE)
    {
        $error_messages[] = check_if_field_submitted('hobbies');
    }

    if (check_if_field_submitted('university') !== TRUE)
    {
        $error_messages[] = check_if_field_submitted('university');
    }

    if (check_if_field_submitted('year') !== TRUE)
    {
        $error_messages[] = check_if_field_submitted('year');
    }

    if (check_if_field_submitted('comments') !== TRUE)
    {
        $error_messages[] = check_if_field_submitted('comments');

    if (count($error_messages) &lt; 1)
    {
        header("Location: success.php");
    }
}


?&gt;


&lt;DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
        &lt;title&gt;&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;

        &lt;?php

        if (isset($error_messages) &amp;&amp; count($error_messages) &gt; 0)
        {
            echo "&lt;ul&gt;";
            foreach($error_messages as $message)
            {
                echo "&lt;li&gt;$message&lt;/li&gt;";
            }
            echo "&lt;/ul&gt;";
        }        

        ?&gt;

      &lt;h1&gt;Register or Fail&lt;/h1&gt;

         &lt;form method="post" action="index.php"&gt;

           &lt;fieldset&gt;

               &lt;label&gt;First Name&lt;/label&gt;
               &lt;input type='text' name='first_name' value="&lt;?php if(isset($_POST['first_name'])) { echo $_POST['first_name']; } ;?&gt;" /&gt;

                &lt;label&gt;Last Name&lt;/label&gt;
                &lt;input type='text' name='last_name' value='&lt;?php if(isset($_POST['last_name'])) { echo $_POST['last_name']; } ;?&gt;'/&gt;

            &lt;/fieldset&gt;

           &lt;fieldset&gt;               
                &lt;label&gt;What are your hobbies?&lt;/label&gt;

                  &lt;input type="checkbox" name="hobbies" value="movies" &lt;?php if(isset($_POST['hobbies']) &amp;&amp; $_POST['hobbies'] == 'movies') { echo "checked='checked'"; } ?&gt; /&gt; Movies
                  &lt;input type="checkbox" name="hobbies" value="sports" &lt;?php if(isset($_POST['hobbies']) &amp;&amp; $_POST['hobbies'] == 'sports') { echo "checked='checked'"; } ?&gt; /&gt; Sports
                  &lt;input type="checkbox" name="hobbies" value="books" &lt;?php if(isset($_POST['hobbies']) &amp;&amp; $_POST['hobbies'] == 'books') { echo "checked='checked'"; } ?&gt; /&gt; Books
                  &lt;input type="checkbox" name="hobbies" value="vgames" &lt;?php if(isset($_POST['hobbies']) &amp;&amp; $_POST['hobbies'] == 'vgames') { echo "checked='checked'"; } ?&gt; /&gt; Video Games 
                  &lt;input type="checkbox" name="hobbies" value="science" &lt;?php if(isset($_POST['hobbies']) &amp;&amp; $_POST['hobbies'] == 'science') { echo "checked='checked'"; } ?&gt; /&gt; FOR SCIENCE!

           &lt;/fieldset&gt;

           &lt;fieldset&gt;

                &lt;label&gt;What year are you?&lt;/label&gt;
                &lt;input type="radio" name="year" value="1" &lt;?php if(isset($_POST['year']) &amp;&amp; $_POST['year'] == '1') { echo "checked='checked'"; } ?&gt; /&gt; Freshman
                &lt;input type="radio" name="year" value="2" &lt;?php if(isset($_POST['year']) &amp;&amp; $_POST['year'] == '2') { echo "checked='checked'"; } ?&gt; /&gt; Sophomore
                &lt;input type="radio" name="year" value="3" &lt;?php if(isset($_POST['year']) &amp;&amp; $_POST['year'] == '3') { echo "checked='checked'"; } ?&gt; /&gt; Junior
                &lt;input type="radio" name="year" value="4" &lt;?php if(isset($_POST['year']) &amp;&amp; $_POST['year'] == '4') { echo "checked='checked'"; } ?&gt; /&gt; Senior
            &lt;/fieldset&gt;

           &lt;fieldset&gt;

               &lt;label&gt;What university are you attending?&lt;/label&gt;

               &lt;select name="university"&gt;
                    &lt;option value="" &lt;?php if(isset($_POST['university']) &amp;&amp; $_POST['university'] == '') { echo "selected='selected'"; } ?&gt; &gt;Please Select an Option&lt;/option&gt;
                    &lt;option value="1" &lt;?php if(isset($_POST['university']) &amp;&amp; $_POST['university'] == '1') { echo "selected='selected'"; } ?&gt; &gt;Florida State University&lt;/option&gt;
                    &lt;option value="2" &lt;?php if(isset($_POST['university']) &amp;&amp; $_POST['university'] == '2') { echo "selected='selected'"; } ?&gt; &gt;University of Florida&lt;/option&gt;
                    &lt;option value="3" &lt;?php if(isset($_POST['university']) &amp;&amp; $_POST['university'] == '3') { echo "selected='selected'"; } ?&gt; &gt;University of Central Florida&lt;/option&gt;
                    &lt;option value="4" &lt;?php if(isset($_POST['university']) &amp;&amp; $_POST['university'] == '4') { echo "selected='selected'"; } ?&gt; &gt;University of Miami&lt;/option&gt;
                &lt;/select&gt;

            &lt;/fieldset&gt;

            &lt;fieldset&gt;
                &lt;button type="submit"&gt;Submit&lt;/button&gt;
           &lt;/fieldset&gt;

        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>
