javascript错误控制台说xml不能是整个程序

The firebug points at the end of the code to '?>' and says XML cant be the whole program, I searched enough about this error but all talk about js & ajax.But my code has only html and i can't find any error here..

<?php 

    $con = mysql_connect('localhost','root','*****');
    if (!$con)
            {
                    die("OOPS!Could not connect to server".mysql_error());
            }
    mysql_select_db('EVENTS',$con) or die('Could not connect'.mysql_error());
            echo "<table>"; 
                    echo "<tr>";
                    echo "<td>"."Time"."</td>" ;
                    $i=0; $j=0;
                    while($i < 7)
                    { $today = mktime(0,0,0,date('d')+$i,date('m'),date('Y'));
                    echo "<td>".date('d/m/Y' , $today)."<br />".date('D',$today)." </td>";
                    $i++;
                    }
                    echo "</tr>";
                    while ($j < 10)
                    {       $i= 0 ; $time = 8+ $j;
                            echo "<tr>";
                            while ( $i < 7)
                            {
                            $today = mktime(0,0,0,date('d')+$i,date('m'),date('Y'));
                            $row1 = mysql_query ("SELECT DESCRIPTION FROM EVENTS WHERE TIME='$time' AND DATE='$today'") or die() ;
                            $row2 = mysql_query ("SELECT NAME FROM EVENTS WHERE TIME='$time' AND DATE='$today'") or die() ;
                            $result1 = mysql_result($row1,$con) or "---";
                            $result2 = mysql_result($row2,$con) or "-";
                            echo "<td>".$result1."BY".$result2."</td>" ;
                            $i++;
                            } echo"</tr>"; $j++;
                    }
            echo "</table>"; mysql_close($con);
     ?>

Here is the code sent to the browser as asked by Quentin,seemingly not different.

  <?php 

$con = mysql_connect('localhost','root','*****');
if (!$con)
            {
                    die("OOPS!Could not connect to server".mysql_error());
            }
mysql_select_db('EVENTS',$con) or die('Could not connect'.mysql_error());
    echo "<table>"; 
        echo "<tr>";
        echo "<td>"."Time"."</td>" ;
        $i=0; $j=0;
        while($i < 7)
        { $today = mktime(0,0,0,date('d')+i,date('m'),date('Y'));
        echo "<td>".date('d/m/Y' , $today)."<br />".date('D',$today)." </td>";
        i++;
        }
        echo "</tr>";
        while ($j < 10)
        {   $i= 0 ; $time = 8+ $j;
            echo "<tr>"
            while ( $i < 7)
            {
            $today = mktime(0,0,0,date('d')+i,date('m'),date('Y'));
            $row1 = mysql_query ("SELECT DESCRIPTION FROM EVENTS WHERE TIME='$time' AND DATE='$today'") or die() ;
            $row2 = mysql_query ("SELECT NAME FROM EVENTS WHERE TIME='$time' AND DATE='$today'") or die() ;
            $result1 = mysql_result($row1,$con) or "---";
            $result2 = mysql_result($row2,$con) or "-";
            echo "<td>".$result1."BY".$result2."</td>" ;
            i++;
            } echo"</tr>"; j++;
        }
    echo "</table>"; mysql_close($con);
      ?>

The .html page when opened in browser shows this:

"; echo ""; echo ""."Time"."" ; $i=0; $j=0; while($i < 7) { $today = mktime(0,0,0,date('d')+i,date('m'),date('Y')); echo "".date('d/m/Y' , $today)." ".date('D',$today)." "; i++; } echo ""; while ($j < 10) { $i= 0 ; $time = 8+ $j; echo "" while ( $i < 7) { $today = mktime(0,0,0,date('d')+i,date('m'),date('Y')); $row1 = mysql_query ("SELECT DESCRIPTION FROM EVENTS WHERE TIME='$time' AND DATE='$today'") or die() ; $row2 = mysql_query ("SELECT NAME FROM EVENTS WHERE TIME='$time' AND DATE='$today'") or die() ; $result1 = mysql_result($row1,$con) or "---"; $result2 = mysql_result($row2,$con) or "-"; echo "".$result1."BY".$result2."" ; i++; } echo""; j++; } echo ""; mysql_close($con); ?>

You are serving PHP to the client instead of running it through the PHP interpretor on the server.

You need to make sure that:

  1. you are accessing the file through a server (and not accessing it from a local file)
  2. the server has PHP installed
  3. the file is recognised by the server as one that should be handled by PHP (this is usually done by giving it a .php file extension)