douyin6188 2015-10-09 08:08
浏览 24
已采纳

PHP代码分析错误

Why is this PHP code wrong in the browser? I don't think there's anything wrong. Error: enter image description here

This is the <body> code:

    <body>
        <center>
            <div class="header">
                MySQL Results
            </div>
        </center>
        <?php
            include_once 'db_functions.php';
            $db = new DB_Functions();
            $users = $db->getAllUsers();
            if ($users != false)
                $no_of_users = mysql_num_rows($users);
            else
                $no_of_users = 0;

        ?>
        <?php
            if ($no_of_users > 0) {
        ?>
        <table>
        <tr id="header"><td>Id</td><td>Username</td></tr>
        <?php
            while ($row = mysql_fetch_array($users)) {
        ?> 
        <tr>
        <td><span><?php echo $row["Id"] ?></span></td>
        <td><span><?php echo $row["Name"] ?></span></td>
        </tr>
        <?php } ?>
        </table>
        <?php }else{ ?>
        <div id="norecord">
        No records in MySQL DB
        </div>
        <?php } ?>
        <div class="refresh">
        <button onclick="refreshPage()">Refresh</button>
        </div>
    </body>
  • 写回答

1条回答 默认 最新

  • duanfu7994 2015-10-09 08:13
    关注

    It looks as though your web server is "preventing" PHP execution properly - and escaping the opening PHP tags <?php to a HTML comment <!--.

    What are you hosting the application on? I'd start by looking for issues there. Your code is fine.


    Update: It's been stated the OP is running Apache Tomcat. I've very little experience of it, but I'm willing to speculate it's the configuration of it which is causing the problem. (Possibly there is no PHP runtime even installed.)

    This SO question seems relevant: Run a php app using tomcat?

    Otherwise I'd suggest to try hosting it someplace else - where it's just straight Apache + PHP.

    One of the StackOverflow sister sites might be better placed for dealing with the server questions if you get stuck configuring it (maybe http://unix.stackexchange.com)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应