$end in script, I can't find the issue
I'm having an issue with one of my scripts, the unexpected $end one. Interestingly, the script works on Linux fine, just not on windows. Here's the script.
<?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> </td>
<td><?php echo $f1; ?></td>
<td> </td>
<td><?php echo $f2; ?></td>
<td> &am开发者_运维问答p;nbsp; </td>
<td><?php echo $f3; ?></td>
<td> </td>
<td><?php echo $f4; ?></td>
<td> </td>
<td><a href=<?php echo "http://$row[ip]:2086"; ?> class="button" target="_blank"> WHM </a> </td>
<td> </td>
<? }?>
</table>
Any ideas on what I've missed out?
There are two possible solutions.
1) To use short open tags, it must be enabled in PHP.INI. Search for short_open_tag in PHP.INI, and change the value to On. The line should look line:
short_open_tag = On
2) Don't use short tags (second to last line):
<?php } ?>
精彩评论