Unexpected $end from calendar script
<p>I can not figure out for the life of me why I get an unexpected $end from this. I've tripple checked and all my php tags are closed properly, so what am I missing? Am I wrong to assume the ?> tag cuts off any running code, even if it has errors in it?</p>

<p>Sorry for the silly question; I just can't seem to figure this one out.</p>

<pre><code>&lt;?php
include'../../includes/head.inc';
include'../../includes/secure.inc';
$monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");

if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
    $cMonth = $_REQUEST["month"];
    $cYear = $_REQUEST["year"];
    $prev_year = $cYear;
    $next_year = $cYear;
    $prev_month = $cMonth-1;
    $next_month = $cMonth+1;

if ($prev_month == 0 ) {
    $prev_month = 12;
    $prev_year = $cYear - 1;
}


if ($next_month == 13 ) {
    $next_month = 1;
    $next_year = $cYear + 1;
}

?&gt;
&lt;div class="calendar"&gt;
&lt;table width="200"&gt;
    &lt;tr align="center"&gt;
        &lt;td&gt;
            &lt;table width="100%" border="0" cellspacing="5"&gt;
                &lt;tr&gt;
                    &lt;td width="50%" align="left"&gt;  &lt;a href="&lt;?php  echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&amp;year=" . $prev_year; ?&gt;" class="cnav"&gt;Previous&lt;/a&gt;&lt;/td&gt;
                    &lt;td width="50%" align="right"&gt;&lt;a href="&lt;?php  echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&amp;year=" . $next_year; ?&gt;" class="cnav"&gt;Next&lt;/a&gt;  &lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td align="center"&gt;
            &lt;table width="100%" border="0" cellpadding="5" cellspacing="5"&gt;
                &lt;tr align="center"&gt;
                    &lt;td colspan="7" style="background: #333; color: #FFF; border: 2px solid #E71; border-radius: 5px; font-size: 2em;"&gt;&lt;strong&gt;&lt;?php  echo $monthNames[$cMonth-1].' '.$cYear; ?&gt;&lt;/strong&gt;&lt;/td&gt;
                &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td align="center" style="background: #333; color: #FFF; border: 2px solid #E71; border-radius: 5px; padding: 10px 20px 10px 20px; font-size: 1.5em;"&gt;&lt;strong&gt;S&lt;/strong&gt;&lt;/td&gt;
                        &lt;td align="center" style="background: #333; color: #FFF; border: 2px solid #E71; border-radius: 5px; padding: 10px 20px 10px 20px; font-size: 1.5em;"&gt;&lt;strong&gt;M&lt;/strong&gt;&lt;/td&gt;
                        &lt;td align="center" style="background: #333; color: #FFF; border: 2px solid #E71; border-radius: 5px; padding: 10px 20px 10px 20px; font-size: 1.5em;"&gt;&lt;strong&gt;T&lt;/strong&gt;&lt;/td&gt;
                        &lt;td align="center" style="background: #333; color: #FFF; border: 2px solid #E71; border-radius: 5px; padding: 10px 20px 10px 20px; font-size: 1.5em;"&gt;&lt;strong&gt;W&lt;/strong&gt;&lt;/td&gt;
                        &lt;td align="center" style="background: #333; color: #FFF; border: 2px solid #E71; border-radius: 5px; padding: 10px 20px 10px 20px; font-size: 1.5em;"&gt;&lt;strong&gt;T&lt;/strong&gt;&lt;/td&gt;
                        &lt;td align="center" style="background: #333; color: #FFF; border: 2px solid #E71; border-radius: 5px; padding: 10px 20px 10px 20px; font-size: 1.5em;"&gt;&lt;strong&gt;F&lt;/strong&gt;&lt;/td&gt;
                        &lt;td align="center" style="background: #333; color: #FFF; border: 2px solid #E71; border-radius: 5px; padding: 10px 20px 10px 20px; font-size: 1.5em;"&gt;&lt;strong&gt;S&lt;/strong&gt;&lt;/td&gt;
                    &lt;/tr&gt;

&lt;?php
mysql_connect ("mysql17.000webhost.com","a6112475_cp","sorry 4 the wait");
mysql_select_db ("a6112475_cp");
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth['wday'];

for ($i=0; $i&lt;($maxday+$startday); $i++) {

    if($cMonth &lt; 10){
        $month_formated = "0$cMonth";
    } else{
        $month_formated = $cMonth;
    }

    if(($i - $startday + 1) &lt; 10){
        $day_formated = "0".($i - $startday + 1)."";
    } else{
        $day_formated = ($i - $startday + 1);
    }

    $dato_formated = "$cYear-$month_formated-$day_formated";
    $get_calendar_data = mysql_query("SELECT * FROM calendar WHERE dato='$dato_formated'");
    $count_rows = mysql_num_rows($get_calendar_data);

    if($count_rows &gt; 0){
        $bgcolor = "#FF0000";
    } else{
        $bgcolor = "#555555";
    }

    $calendar_data = mysql_fetch_assoc($get_calendar_data);
    $heading = $calendar_data['heading'];
    mysql_close();
    for ($i=0; $i&lt;($maxday+$startday); $i++) {      
        if(($i % 7) == 0 ){
            echo "&lt;tr&gt;";
        }
        if($i &lt; $startday){
            echo ("&lt;td class='cell cell_txt'&gt; &lt;/td&gt;");
        } else {            
            if (($i - $startday + 1) == $today &amp;&amp; $currentmonth == $cMonth){
                echo ("&lt;td class='cell_today cell_txt'&gt;".($i-$startday+ 1)."&lt;/td&gt;");
            } else {
                echo ("&lt;td class='cell cell_txt'&gt;".($i - $startday + 1)."&lt;/td&gt;");
            }
        }       
        if(($i % 7) == 6 ) {
            echo "&lt;/tr&gt;\n";
        }
    }
?&gt;

            &lt;/table&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;?php include'../../includes/footer.inc'; ?&gt;
</code></pre>
