-1
if ($_SESSION["readyChatUser"] != "") {?>
<div class="portlet box green">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-cogs"></i><?php echo $_SESSION["readyChatUser"];?>'s Portfolio </div>
<div class="actions">
<!--<a href="javascript:;" class="btn btn-default btn-sm">
<i class="fa fa-pencil"></i> Edit </a>-->
<a href="#add" data-toggle="modal" class="btn btn-default btn-sm">
<i class="fa fa-plus"></i> Add </a>
</div>
</div>
<div class="portlet-body flip-scroll">
<table class="table table-bordered table-striped table-condensed flip-content" id="portfolio">
<thead class="flip-content">
<tr>
<th width="10%"> # </th>
<th> Name </th>
<th class="numeric"> Price (USD) </th>
<th class="numeric"> Price (BTC) </th>
<th class="numeric"> Change (USD) </th>
<th class="numeric"> Change (%) </th>
<th class="numeric"> Value (USD) </th>
<th class="numeric"> Value (BTC) </th>
<th class="numeric"> Bought at </th>
<th class="numeric"> Amount </th>
</tr>
</thead>
<tbody>
<?php
$balancesquery = $mysqli->query("SELECT * FROM `tracker` WHERE `userid` = '{$GLOBALS["user"]["user_id"]}'");
$balances = array();
$total_btc = 0;
$total_usd = 0;
while($rows = $balancesquery->fetch_array(MYSQLI_BOTH)){
$currency[] = $rows;
}
foreach($currency as $cryptobalance){
$BTCtoUSD = "https://api.coinmarketcap.com/v1/ticker/{$cryptobalance['currency']} ?>";
$jsonBTC = file_get_contents($BTCtoUSD, false);
$json_data_BTC = json_decode($jsonBTC, true);
$coin = $json_data_BTC[0];
$value_usd = $coin['price_usd'] * $cryptobalance['amount'];
$value_btc = $coin['price_btc'] * $cryptobalance['amount'];
$total_usd = $total_usd + $value_usd;
$total_btc = $total_btc + $value_btc;
$change_usd = $coin['price_usd'] * $cryptobalance['amount'] - $cryptobalance['start_price'] * $cryptobalance['amount'];
$x = ($cryptobalance['start_price'] * $cryptobalance['amount']);
$y = ($coin['price_usd'] * $cryptobalance['amount']);
$percent = $x/$y;
$change_btc = get_percentage($x,$y) - 100;
?>
<tr>
<td> <?php echo $counter; ?> </td>
<td> <?php echo $cryptobalance['full_name']; ?> </td>
<td class="numeric"> $ <?php echo $coin['price_usd']; ?> </td>
<td class="numeric"> <?php echo $coin['price_btc']; ?> BTC </td>
<td class="numeric"> $ <?php echo $change_usd; ?> </td>
<td class="numeric"> <?php if($change_usd < 0){ echo $change_btc;} else{ echo $change_btc;} ?> %</td>
<td class="numeric"> $ <?php echo $value_usd; ?> </td>
<td class="numeric"> <?php echo $value_btc; ?> BTC </td>
<td class="numeric"> $ <?php echo $cryptobalance['start_price']; ?> </td>
<td class="numeric"> <?php echo $cryptobalance['amount']; ?> </td>
<td style=""><center><a href="#delete" data-toggle="modal" id="deletecoin" class="btn btn-circle btn-icon-only btn-default deletecoin">
<i class="icon-trash"></i>
</a></center></td>
<td style="display:none;"><span class="idcrypto" id="coinsid"><?php echo $cryptobalance['id']; ?></span> </td>
</tr>
<?$counter = $counter+1;}
?>
</tbody>
</table>
Total: <span id="totalvalue"><?php echo $total_usd; ?></span> USD = <?php echo $total_btc; ?> BTC
</div>
</div>
<?php } else { ?>
<div class="alert alert-block alert-danger fade in">
<button type="button" class="close" data-dismiss="alert"></button>
<h4 class="alert-heading">Error!</h4>
<p> To use LastCrypto's Portfolio Tracker, please log in. </p>
<p>
<a class="btn blue" href="login.php"> Login </a>
</p>
</div>
<div class="well">
<h3>
</h3>
</div>
<?php } ?>
這對我的本地開發機器來說工作得很好。PHP代碼在本地工作,但解析生產中的錯誤
,但我的服務器上它給了我
Parse error: syntax error, unexpected 'else' (T_ELSE)
即使我刪除else分支它給
unexpected end of file
當我刪除,我只是在這裏張貼正常工作沒有錯誤的完整部分所以問題必須在那裏。 我不知道,請幫助我。
這是因爲不同的PHP版本或什麼。我的網站是巨大的,我有類似的網站,工作得很好。
短服務器在服務器上關閉。你可以通過剝離不相關的代碼創建一個[mcve],直到問題消失,然後添加你刪除的最後一位,然後查看與其他行的區別。提示:這是'<?$ counter = $ counter + 1;} '。 – CodeCaster
短暫開啓。或用'<?php'替換每個<?' –