$ end脚本,我找不到问题

时间:2010-12-24 21:33:58

标签: php

我的一个脚本出现问题,意外的$ end结尾。有趣的是,该脚本在Linux上工作正常,而不是在Windows上。这是剧本。

<?php
$finding = $db->query_read("SELECT * FROM `servers` ORDER BY `id` ASC LIMIT 0, 30 ");
  while($row=mysqli_fetch_array($finding)){
      echo "<tr class='alt2'>";

      $whmusername = "root";
      $whmhash = $row['accesshash'];

      $query = "http://$row[ip]:2086/xml-api/loadavg";

      $curl = curl_init(); # Create Curl Object
      curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); 
      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
      $header[0] = "Authorization: WHM $whmusername:" . preg_replace("'(\r|\n)'", "",
$whmhash); # Remove newlines from the hash
      curl_setopt($curl, CURLOPT_HTTPHEADER, $header); # Set curl header
      curl_setopt($curl, CURLOPT_URL, $query); # Set your URL
      $result = curl_exec($curl); # Execute Query, assign to $result
      if ($result == false) {
          error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");
      }
      curl_close($curl);


      $root = new SimpleXMLElement($result);
      $loadavg = array((string) $root->one, 
             (string) $root->five, 
             (string) $root->fifteen);

      $query = "http://$row[ip]:2086/xml-api/listaccts";                
      $curl = curl_init(); # Create Curl Object
      curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
      $header[0] = "Authorization: WHM $whmusername:" . preg_replace("'(\r|\n)'", "",
$whmhash); # Remove newlines from the hash
      curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
      curl_setopt($curl, CURLOPT_URL, $query);
      $acct = curl_exec($curl);
      if ($acct == false) {
          error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");
      }
      curl_close($curl);

      $acctcnt = new SimpleXMLElement($acct);   
      $acccount = count($acctcnt->acct);          

      $f1=$row['hostname'];
      $f2=$row['ip'];
      $f3="$loadavg[0]  $loadavg[1]  $loadavg[2]";
      $f4 = $acccount;

      ?>
      <td>&nbsp;&nbsp;&nbsp;</td>
      <td><?php echo $f1; ?></td>
      <td>&nbsp;&nbsp;&nbsp;</td>
      <td><?php echo $f2; ?></td>
      <td>&nbsp;&nbsp;&nbsp;</td>
      <td><?php echo $f3; ?></td>
      <td>&nbsp;&nbsp;&nbsp;</td>
      <td><?php echo $f4; ?></td>
      <td>&nbsp;&nbsp;&nbsp;</td>
      <td><a href=<?php echo "http://$row[ip]:2086"; ?> class="button"           target="_blank">&nbsp;WHM&nbsp;</a>&nbsp;</td>
      <td>&nbsp;&nbsp;&nbsp;</td>
 <? }?>
 </table>

关于我错过的任何想法?

1 个答案:

答案 0 :(得分:1)

有两种可能的解决方案。

1)要使用短打开标记,必须在PHP.INI中启用它。在PHP.INI中搜索short_open_tag,并将值更改为On。该行应该看起来像行:

short_open_tag = On

2)不要使用短标签(倒数第二行):

<?php } ?>