doh85 Posted December 6, 2010 Share Posted December 6, 2010 if($ns_cb->targetCurrency == 'USD') { $usd_base_rate = '1'/$ns_cb->value; } $eq = number_format($usd_base_rate*$ns_cb->value,2); echo $eq $ns_cb->value is currently = 0.9940. But this gets updated every day. I keep getting division by zero for this problem here, any help? Link to comment https://forums.phpfreaks.com/topic/220834-division-by-zero-help/ Share on other sites More sharing options...
bugcoder Posted December 6, 2010 Share Posted December 6, 2010 just add a check before division to ensure it doesnt get divided by zero if(!empty($ns_cb->value)){ $usd_base_rate = '1'/$ns_cb->value; } Link to comment https://forums.phpfreaks.com/topic/220834-division-by-zero-help/#findComment-1143607 Share on other sites More sharing options...
AbraCadaver Posted December 6, 2010 Share Posted December 6, 2010 $ns_cb->value is NOT currently = 0.9940 or you wouldn't get this error. Link to comment https://forums.phpfreaks.com/topic/220834-division-by-zero-help/#findComment-1143608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.