이전 목록 다음
채택완료

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 포인트

$graph1 = ($visit[1]/$visit[2])*100 ;

을 이렇게 바꾸시면 되지 않을까요?

$graph1 = 0

if ( visit[2] != 0 ) $graph1 = ($visit[1]/$visit[2])*100 ;

답변에 대한 댓글 5개

이렇게 하닌까
$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
if ( $visit[2] != 0 ) $graph1 = ($visit[1]/$visit[2])*100 ;

if 문에 $ 이 빠졌네요 ..ㅋ
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;
?>
$graph1 = 0;

syntax error 이면 저기 위에 ";" 빠졌네요.
작동을 하는지 않하는지는 모르겠어요 우선 에러는 안뜨네요 감ㅅ합니다^^;;

답변을 작성하려면 로그인이 필요합니다.