Raiso Posted January 18, 2009 Share Posted January 18, 2009 I have a error Warning: Division by zero in /stats.php on line 40 this is the line $avgb=(int) ($totalb/$banks); someone know another solution to fix this? Link to comment https://forums.phpfreaks.com/topic/141382-solved-little-error/ Share on other sites More sharing options...
premiso Posted January 18, 2009 Share Posted January 18, 2009 Don't divide by zero. You can use an if to check if $banks is 0 if it is then do not divide by it. If you are getting an unexpected zero there I would check the logic where $banks is set. Link to comment https://forums.phpfreaks.com/topic/141382-solved-little-error/#findComment-740041 Share on other sites More sharing options...
Raiso Posted January 18, 2009 Author Share Posted January 18, 2009 No thats not the problem, The problem is (INT) i think Link to comment https://forums.phpfreaks.com/topic/141382-solved-little-error/#findComment-740042 Share on other sites More sharing options...
trq Posted January 18, 2009 Share Posted January 18, 2009 No thats not the problem, The problem is (INT) i think How do you know that isn't the problem? Link to comment https://forums.phpfreaks.com/topic/141382-solved-little-error/#findComment-740046 Share on other sites More sharing options...
Raiso Posted January 18, 2009 Author Share Posted January 18, 2009 I already triet that and it doesn't work Link to comment https://forums.phpfreaks.com/topic/141382-solved-little-error/#findComment-740047 Share on other sites More sharing options...
premiso Posted January 18, 2009 Share Posted January 18, 2009 No thats not the problem, The problem is (INT) i think lmao, whatever you say man. I do not know what I am doing and I obviously do not know how to read an error. Humor me and before you divide by zero echo out $banks and see what is printed out. EDIT: And for giggles I ran this just fine: <?php $totalb = 5; $banks = 2; $avgb=(int) ($totalb/$banks); echo "Avgb: " . $avgb; die(); ?> Link to comment https://forums.phpfreaks.com/topic/141382-solved-little-error/#findComment-740048 Share on other sites More sharing options...
Raiso Posted January 18, 2009 Author Share Posted January 18, 2009 I already fixt it Thnx anyway everyone Grtz, Raiso Link to comment https://forums.phpfreaks.com/topic/141382-solved-little-error/#findComment-740051 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.