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

    function Pagination($config=array()){
            $firstpage = 'First';
            $lastpage = 'Last';
            $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($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> . . . ';
        ////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>';
                $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

Recommended Answers

All 2 Replies

Surely if you purchased this then you should go back to the vendor and insist they fix it or refund your money.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.