# Thread: PHP Scripting Math Problem

1. I am working on a poject and I am having problem with a script I had done.

Go to:
http://www.dotdealers.com/calc.php

Enter 29.95 and click Calculate Profit. See where it says \$1.410 (credit card processing fee - 5%)... It should come out with \$1.50. The credit card processing fee should be 5% of the amount entered. It works correctly with most amounts entered, but not all.

Here's the script:
http://www.dotdealers.com/calc.txt

Any help would be greatly appreciated!

Thanks,

Doug

2. I changed your script a bit, and got rid of some unnecessary code, I think this is what you want

PHP Code:
``` <font face="Verdana, Arial" size=2> <? if(\$submit){     //check price is high enough     if(\$price<10.45){      echo '<B>Price too low!! Must be at least \$10.45</B><BR>';      \$submit="";     }else{             //calculate variables             \$user_cost=9.95;             \$credit_fee=number_format((\$price*0.05), 2);             \$profit=number_format((\$price-\$credit_fee-\$user_cost), 2); echo "If you charged <b>\\$\$price</b>, you would make <b>\\$\$profit</b> per domain sold!<BR>"; echo "Here is how it breaks down: \\$\$price (price you are charging) minus <b>\\$\$credit_fee</b> (credit card processing fee - 5%), minus <b>\\$9.95</b> (your cost) equals <b>\\$\$profit</b> (Profit per domain)."; echo '<P><P>'; } \$submit=""; } if(!\$submit){ //display the form echo 'How much do you wish to sell domains to your clients for??<br> [Enter numbers only. Does not need \$ sign.]<p> <form> <input type=text name=price> <input type=hidden name=submit value=go> <input type=submit name=some value="Calculate Profit"> </form>'; } ?> ```

3. Freddy... You are awesome!

Works like a charm...
http://www.dotdealers.com/calc1.php

Thanks a ton!

Doug

4. No sweat!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•