0

hi all i have recently purchased a script and im attempting to fix it would anyone know how to solve these 2 errors which appear to be coming from this function

[09-Jun-2018 12:40:57 UTC] PHP Warning: Division by zero in /home/public_html/includes/functions.php on line 126
[09-Jun-2018 12:41:19 UTC] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /home/public_html/includes/functions.php on line 135

if(!function_exists('Pagination')){
    function Pagination($config=array()){
        if($_SESSION['lang']=='L1'){
            $firstpage = 'First';
            $lastpage = 'Last';
            }
        else{
            {
            $firstpage = 'Trang đầu';
            $lastpage = 'Trang cuối';
            }
            }
        $output = '';
        ////FIRST ERROR $rs_maxpage = $config['js_numrows_page']>0?ceil($config['js_numrows_page']/$config['per_page']):0;
        $eitherside = ($config['showeachside'] * $config['per_page']);
        $paga = (strpos($config['cururl'], '?')!==false)?'&p=':'?p=';
        if($rs_maxpage>1){
            if($config['rs_start']+1 > $eitherside){
                $page = $config['curpage'] - 1;
                $output .= '<a href="'.$config['cururl'].'"><i>'.$firstpage.'</i></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$config['cururl'].$paga.$page.'"><i><<</i></a> . . . ';
                }
                $pg=1;
        ////SECOND ERROR    for($y=0; $y<$config['js_numrows_page']; $y+=$config['per_page']){
                if(($y > ($config['rs_start'] - $eitherside)) && ($y < ($config['rs_start'] + $eitherside)))
                    $output .= ($pg==$config['curpage'])?'<b> &nbsp;'.$pg.'</b>':' &nbsp;<a href="'.$config['cururl'].$paga.$pg.'">'.$pg.'</a>';
                $pg++;
                }
            if(($config['rs_start']+$eitherside)<$config['js_numrows_page']){
                $page = $config['curpage'] + 1;
                $output .=  ' . . . <a href="'.$config['cururl'].$paga.$page.'"><i>>></i></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$config['cururl'].$paga.$rs_maxpage.'"><i>'.$lastpage.'</i></a>';
                }
            }
        return $output;
        }
    }

Any help would be much appreciated ty jan x

3
Contributors
2
Replies
18
Views
4 Months
Discussion Span
Last Post by rproffitt
0

So no line 126? I can't guess if you commented your line 14 but while James is right, just like any debugging you dump the variables and see why it failed. As this code seems to rely on data not in the post you have to work it out yourself.

Just a thought. It looks like a report but what if the database had no matching records and the page count was zero? Then it should do this. But that's just code that wasn't coded to handle that condition.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.