dongshenchi5364 2013-11-04 22:28
浏览 39
已采纳

将<?php?>添加到<TD>中

I'm still new a PHP so i'm trying to figure things out as I go.

There is one thing puzzling me.

    (LINE 51) <TD><?php

$data = file_get_contents("http://awebsite.com/status?server_ip={$s['ip']}&clean=true");

if($data == 'true') {
echo 'Online';
} else {

echo 'Offline';
}

?></TD>

This seems to shoot out the error that

 Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in home.php on line 53

Thanks in advance

PRIOR CODE @MattClark

<?php
                while($s = mysql_fetch_array($sq)) {
                    echo"

          <!-- Server Box - Table Method -->
                    <tr class='server'>
                       <td></td>
                       <td><a href='".$url."?p=server&s_id=".$s['s_id']."'>".$s['name']."</a></td>
                       <td><img class='default' src='".$url."images/countries/".$s['country'].".png' title='".$s['country']."' /> ".$s['country']." </td>
                       <td>".$s['type']."</td>
                       <td>".$s['votes']."</td>
                       <td><?php

$data = file_get_contents("http://awebsite.com/status?server_ip={$s['ip']}&clean=true");

if($data == 'true') {
echo 'The server is online';
} else {

echo 'The server is offline';
}

?></td>
                       <td></td>
                    </tr>
  • 写回答

2条回答 默认 最新

  • dsgrs26202 2013-11-04 22:52
    关注

    This should fix your syntax error you also have forgot } to while loop

    <?php
    while($s = mysql_fetch_array($sq)) {
    echo"
    
    <!-- Server Box - Table Method -->
    <tr class='server'>
    <td></td>
    <td><a href='".$url."?p=server&s_id=".$s['s_id']."'>".$s['name']."</a></td>
    <td><img class='default' src='".$url."images/countries/".$s['country'].".png' title='".$s['country']."' /> ".$s['country']." </td>
    <td>".$s['type']."</td>
    <td>".$s['votes']."</td>
    <td>";
    
    $data = file_get_contents("http://awebsite.com/status?server_ip={$s['ip']}&clean=true");
    
    if($data == 'true') {
    echo 'The server is online';
    } else {
    
    echo 'The server is offline';
    }
    
    ?></td>
    <td></td>
    </tr>
    <?php }?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能