2013-11-04 49 views
1

我还是新来的PHP,所以我试图在事情发展的时候把它弄清楚。将<?php ?>加入<TD>

有一件事让我困惑。

(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> 

这似乎拍出来的错误

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

在此先感谢

在前代码@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> 
+0

您运行的是什么版本的PHP? – Nightfirecat

+3

看看前面的'php'标签,我敢打赌,你最终错过了''''; –

+1

第53行的错误并不一定表示问题出在哪里。它可能是上面的一行,缺少';'或范围未正确关闭。 – mellamokb

回答

1

这应该可以解决你的语法错误,你也忘了}到while循环

<?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 }?> 
0

更改此:

<td>".$s['votes']."</td> 
<td><?php 

要这样:

<td>".$s['votes']."</td> 
<td>"; 

你还没有完成你的说法,回声尚未关闭,而你试图打开一个<?php标签,同时还是一个<?php标签内。

相关问题