为统计信息创建文件,我遇到此错误:
内部服务器错误
除以零
Web服务器处理您的请求时发生内部错误。请与网站站长联系以报告此问题。
谢谢。
我该如何解决这个问题? 这是代码:
$theme = Yii::app()->theme->name;
echo CHtml::cssFile(Yii::app()->getBaseUrl(true).'/public/themes/'.$theme.'/css/jquery.jqplot.min.css');
echo CHtml::scriptFile(Yii::app()->getBaseUrl(true).'/public/themes/'.$theme.'/js/jquery.jqplot.min.js');
echo CHtml::scriptFile(Yii::app()->getBaseUrl(true).'/public/themes/'.$theme.'/js/jqplot.donutRenderer.min.js');
echo CHtml::scriptFile(Yii::app()->getBaseUrl(true).'/public/themes/'.$theme.'/js/jqplot.pieRenderer.min.js');
?>
<div class="row-fluid">
<div class="well">
<table>
<tr>
<td width="50%"><h1>Booking progress</h1><div id="flight" style="height:300px; width:500px;"></div></td>
<td width="50%"><h1>Slot reservation progress</h1><div id="slot" style="height:300px; width:500px;"></div></td>
</tr>
</table>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
var dataf = [
['Free to book', <?php echo floor(100 - $progress * 100); ?>],['Booked flights', <?php echo floor($progress * 100); ?>]
];
var datas = [
['Free slots', <?php echo floor(100 - $sprogress * 100); ?>],['Reserved slots', <?php echo floor($sprogress * 100); ?>]
];
var fplot = jQuery.jqplot ('flight', [dataf],
{
seriesDefaults: {
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
showDataLabels: true,
dataLabels: 'percent'
}
},
legend: { show:true, location: 's' }
}
);
var splot = jQuery.jqplot ('slot', [datas],
{
seriesDefaults: {
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
showDataLabels: true,
dataLabels: 'percent'
}
},
legend: { show:true, location: 's' }
}
);
});
</script>
这是控制器
public function actionProgress()
{
$flc = FlightModel::model()->count();
$bc = BookModel::model()->count();
$progress = $bc / $flc;
$slc = SlotModel::model()->count();
$sc = SlotreserveModel::model()->count();
$sprogress = $sc / $slc;
$this->render('progress', array('progress' => $progress, 'sprogress' => $sprogress));
}
}
答案 0 :(得分:1)
嗯,你这样做
$progress = $bc / $flc;
$sprogress = $sc / $slc;
$ flc或$ slc或两者都是0.可能你正在搜索不存在的记录。
除以0的任何东西都是无穷大=&gt;确切的错误。
您可以将这两行更改为
$progress = $flc > 0 ? $bc / $flc : 0;
$sprogress = $slc > 0 ? $sc / $slc : 0;