채택완료
Division by zero 이거 없앨려면 어떻게 해야하나요? 방문자관련 소스입니다
밑에 소스를 가지고 적용을 했는데 0이라 에러 뜨는거 같은데 어떻게 해야하나요?
Warning: Division by zero in /home/cwy/visit.skin.php on line 10
Compared with yesterday
Copy
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
global $is_admin;
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
//Code By Day (http://dayever.me/)
add_stylesheet('<link rel="stylesheet" href="'.$visit_skin_url.'/style.css">', 0);
$graph1 = ($visit[1]/$visit[2])*100 ;
$graph = floor($graph1);
$last = 100-$graph;
?>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script src='https://code.jquery.com/jquery-2.2.4.min.js'></script>
<script>
(function($) {
$.fn.counter = function(options) {
var settings = $.extend({
start: 0,
end: 100,
easing: 'swing',
duration: 400,
complete: ''
}, options);
var thisElement = $(this);
$({
count: settings.start
}).animate({
count: settings.end
}, {
duration: settings.duration,
easing: settings.easing,
step: function() {
var mathCount = Math.ceil(this.count);
thisElement.text(mathCount);
},
complete: settings.complete
});
};
}(jQuery));
$(document).ready(function() {
$('.score-graph').each(function() {
$(this).find('.score-graph-bar').animate({
width: $(this).attr('data-percent')
}, 2300);
});
});
</script>
<!-- 접속자집계 시작 { -->
<div class="maint">
<div id="score-counter" class="total-score"><?php echo $visit[1];?></div>
<div class="score-range">Compared with yesterday</div>
<div class="score-graph" data-percent="<?php echo $last;?>%">
<div class="score-graph-bar">
<span><i class="fa fa-star" aria-hidden="true"></i></span>
</div>
</div>
<!-- ./score-graph-->
<style>
.score-graph:after {
content: '<?php echo $visit[2];?>';
}
</style>
</div>
답변 1개 / 댓글 5개
채택된 답변
+20 포인트
2018-04-20 (금) 09:47:33
$graph1 = ($visit[1]/$visit[2])*100 ;
을 이렇게 바꾸시면 되지 않을까요?
$graph1 = 0
if ( visit[2] != 0 ) $graph1 = ($visit[1]/$visit[2])*100 ;
답변에 대한 댓글 5개
zkdlf
2018-04-20 (금) 10:29:40
2018-04-20 (금) 10:40:37
if ( $visit[2] != 0 ) $graph1 = ($visit[1]/$visit[2])*100 ;
if 문에 $ 이 빠졌네요 ..ㅋ
if 문에 $ 이 빠졌네요 ..ㅋ
zkdlf
2018-04-20 (금) 12:33:59
Parse error: syntax error, unexpected T_IF in /cwy/visit.skin.php on line 5
똑같아요^^;; 죄송
<?php
$graph1 = 0
if ( $visit[2] != 0 ) $graph1 = ($visit[1]/$visit[2])*100 ;
$graph = floor($graph1);
$last = 100-$graph;
?>
똑같아요^^;; 죄송
<?php
$graph1 = 0
if ( $visit[2] != 0 ) $graph1 = ($visit[1]/$visit[2])*100 ;
$graph = floor($graph1);
$last = 100-$graph;
?>
답변을 작성하려면 로그인이 필요합니다.
$graph1 = 0
if ( visit[2] != 0 ) $graph1 = ($visit[1]/$visit[2])*100 ;
$graph = floor($graph1);
$last = 100-$graph;
?>
이렇게 뜨는데...^^;;
Parse error: syntax error, unexpected T_IF in /cwy/visit.skin.php on line 12