dra8603 2012-10-07 17:02
浏览 19
已采纳

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); ?>

  • 写回答

1条回答 默认 最新

  • duanlumei5941 2012-10-07 17:30
    关注

    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)
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧