DesignLoft Posted December 23, 2006 Posted December 23, 2006 Well now i'm out of the beta phase I decided to make it more user friendly and i thought to place the users stats, like brave etc.. into the main menu. like on monocountry. so i copy this code over as it is required: function userdata($ir,$lv,$fm,$cm,$dosessh=1) $enperc=(int) ($ir['energy']/$ir['maxenergy']*100); $wiperc=(int) ($ir['will']/$ir['maxwill']*100); $experc=(int) ( $ir['exp']/$ir['exp_needed']*100); $brperc=(int) ($ir['brave']/$ir['maxbrave']*100); $hpperc=(int) ($ir['hp']/$ir['maxhp']*100); $enopp=100-$enperc; $wiopp=100-$wiperc; $exopp=100-$experc; $bropp=100-$brperc; $hpopp=100-$hpperc; $d=""; and then where appropriate i add print " [b]Your Stats[/b] [b]Energy:[/b] {$enperc}% [b]Will:[/b] {$wiperc}% [b]Brave:[/b] {$ir['brave']}/{$ir['maxbrave']} [b]EXP:[/b] {$experc}% [b]Health:[/b] {$hpperc}% then the error appears as: Warning: Division by zero in /usr/home/ben/public_html/mafia/mainmenu.php on line 2 Warning: Division by zero in /usr/home/ben/public_html/mafia/mainmenu.php on line 3 Warning: Division by zero in /usr/home/ben/public_html/mafia/mainmenu.php on line 4 Warning: Division by zero in /usr/home/ben/public_html/mafia/mainmenu.php on line 5 Warning: Division by zero in /usr/home/ben/public_html/mafia/mainmenu.php on line 6 any ideas why? I know php doesn't allow division by zero as it is impossible. But since i copied it over from header.php where it was working i cannot see why? Quote
DesignLoft Posted December 24, 2006 Author Posted December 24, 2006 Re: Division by zero error when moving the "users stats" into the mainmenu.php Bump :) Quote
ddupuis Posted December 29, 2009 Posted December 29, 2009 Well now i'm out of the beta phase I decided to make it more user friendly and i thought to place the users stats, like brave etc.. into the main menu. like on monocountry. so i copy this code over as it is required: function userdata($ir,$lv,$fm,$cm,$dosessh=1) $enperc=(int) ($ir['energy']/$ir['maxenergy']*100); $wiperc=(int) ($ir['will']/$ir['maxwill']*100); $experc=(int) ( $ir['exp']/$ir['exp_needed']*100); $brperc=(int) ($ir['brave']/$ir['maxbrave']*100); $hpperc=(int) ($ir['hp']/$ir['maxhp']*100); $enopp=100-$enperc; $wiopp=100-$wiperc; $exopp=100-$experc; $bropp=100-$brperc; $hpopp=100-$hpperc; $d=""; and then where appropriate i add print " Your Stats Energy: {$enperc}% Will: {$wiperc}% Brave: {$ir['brave']}/{$ir['maxbrave']} EXP: {$experc}% Health: {$hpperc}% then the error appears as: Warning: Division by zero in /usr/home/ben/public_html/mafia/mainmenu.php on line 2 Warning: Division by zero in /usr/home/ben/public_html/mafia/mainmenu.php on line 3 Warning: Division by zero in /usr/home/ben/public_html/mafia/mainmenu.php on line 4 Warning: Division by zero in /usr/home/ben/public_html/mafia/mainmenu.php on line 5 Warning: Division by zero in /usr/home/ben/public_html/mafia/mainmenu.php on line 6 any ideas why? I know php doesn't allow division by zero as it is impossible. But since i copied it over from header.php where it was working i cannot see why? The variables here are being assigned values by the "include globals.php" in the header file. so after you have cut it out from the header it's not going to be assigned any value there for 0 is assigned. Quote
Zero-Affect Posted December 29, 2009 Posted December 29, 2009 i seem to remember having this error when i first started messing with MC it's a 0 in a grabbed column in the database i believe. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.