Division by zero error in char.php

Requests, feedback, and general discussion about WoWRoster
DO NOT post topics about WoWRoster AddOns here!

Division by zero error in char.php

Postby robweeks » Wed Oct 25, 2006 12:35 pm

Warning: Division by zero in MY_PATH_TO_ROOT\roster\lib\char.php on line 1503

Ive attached a screenshot.

Thought id best report it before he uploads data again and values change
Attachments
divbyzero.jpg
divbyzero.jpg (50.95 KiB) Viewed 491 times
ImageImage
robweeks
WR.net Apprentice
WR.net Apprentice
 
Posts: 45
Joined: Tue Jul 04, 2006 8:17 pm

Division by zero error in char.php

Postby PleegWat » Wed Oct 25, 2006 1:45 pm

I think I've heard this error before somewhere, possibly on IRC. It's caused by the maxXP not being in the profile, so 0 is stored in the DB. But that causes a division by zero when rendering the status bar.

The fix: In char.php, near the top, find this function:

Code: Select all

    
function printXP()
    {
        list(
$current$max) =
        
explode':'$this->data['exp'] );

        
$perc='';
        if (
$current 0)
        {
            
$perc round(($current $max)* 2481);
        }
        return 
$perc;
    }
 


Replace by this:

Code: Select all

    
function printXP()
    {
        list(
$current$max) =
        
explode':'$this->data['exp'] );
        if (
$max 0)
        {
            
$max 1;
        }

        
$perc='';
        if (
$current 0)
        {
            
$perc round(($current $max)* 2481);
        }
        return 
$perc;
    }
 
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm

Division by zero error in char.php

Postby zanix » Wed Oct 25, 2006 2:00 pm

Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Division by zero error in char.php

Postby robweeks » Wed Oct 25, 2006 5:43 pm

nice guys, ty
ImageImage
robweeks
WR.net Apprentice
WR.net Apprentice
 
Posts: 45
Joined: Tue Jul 04, 2006 8:17 pm


Return to General Support & Feedback

Who is online

Users browsing this forum: No registered users and 1 guest

cron