Forum Moderators: coopster

Message Too Old, No Replies

Error Calculating

         

AranhaHunter

11:53 pm on Dec 20, 2005 (gmt 0)

10+ Year Member



Guys I'm getting an error and I really don't know why.

I get the values from a form page and I add all the values put, to get a subtotal. So far, so good. It adds perfectly. I then get this subtotal value and multiply it by 2.35 to give it a total. It works great as long as the subtotal is under 1000. I don't know why it doesn't work. This is the part of the code where it doesn't work as I would like it to. All this is supposed to do is give the value of dollars in a foreign coin.

echo 'Dollars:$'.$totalamount."<br>";//this works

$totalamount = $totalamount * 2.35;

$totalamount = number_format($totalamount, 2);

echo 'Reais:$'.$totalamount.'<br>';

Any help would be greatly appreciated

anchordesk

12:04 am on Dec 21, 2005 (gmt 0)

10+ Year Member



Does $totalamount contain a comma?

AranhaHunter

2:13 pm on Dec 21, 2005 (gmt 0)

10+ Year Member



Yes, this is $totalamount:

$totalamount = $amount1 + $amount2 + $amount3;

$totalamount = number_format($totalamount, 2);

echo '<br>';
echo 'Dollars:$'.$totalamount."<br>";

anchordesk

2:50 pm on Dec 21, 2005 (gmt 0)

10+ Year Member



I think you need to make sure that ...

$totalamount = $totalamount * 2.35;

... is performed without any commas in $totalamount.