canadian_angel Posted June 14, 2010 Share Posted June 14, 2010 <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <title>Product Cost</title> </head> <body> <?php // Script 4.5 - handle_calc.php /*This script takes values from calculator.html and performs total cost and monthly payment calculations. */ // Address error handling. ini_set ('display_errors', 1); error_reporting(E_ALL & ~E_NOTICE); // In case register_globals is enabled. $price = $_POST['price']; $quantity = $_POST['quantity']; $discount = $_POST['discount']; $tax = $_POST['tax']; $shipping = $_POST['shipping']; $payments = $_POST['payments']; // Calculate the total $total=(($price * $quantity) + $shipping) - $discount; // Determine the tax rate $taxrate = $tax/100; $taxrate++; // Factor in the tax rate. $total = $total * $taxrate; // Calculate the monthly payments. $monthly = $total / $payments; // Apply the proper formatting. $total = number_format ($total, 2); $monthly = number_format ($monthly, 2); // Print out the results. print "You have selected to purchase:<br /> <b>$quantity</b> widget(s) at <br /> $<b>$price</b> price with a <br /> $<b>$shipping</b> shipping cost and a <br /> <b>$tax</b> percent tax rate. <br /> After your $<b>$discount</b> discount, the total cost is $<b>$total</b>.<br /> Divided over <b>$payments</b> monthly payments, that would be $<b>$monthly</b> each."; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/204768-code-producing-error-message-and-i-cant-figure-out-why/ Share on other sites More sharing options...
hcdarkmage Posted June 14, 2010 Share Posted June 14, 2010 Please post the error. Link to comment https://forums.phpfreaks.com/topic/204768-code-producing-error-message-and-i-cant-figure-out-why/#findComment-1072033 Share on other sites More sharing options...
kenrbnsn Posted June 14, 2010 Share Posted June 14, 2010 And the error is??? When you post code on this forum, please put the tags at the beginning and end. Ken Link to comment https://forums.phpfreaks.com/topic/204768-code-producing-error-message-and-i-cant-figure-out-why/#findComment-1072034 Share on other sites More sharing options...
canadian_angel Posted June 14, 2010 Author Share Posted June 14, 2010 Error message: Warning: Division by zero in C:\AppServ\www\chapter4\handle_calc.php on line 37 You have selected to purchase: widget(s) at $ price with a $ shipping cost and a percent tax rate. After your $ discount, the total cost is $0.00. Divided over monthly payments, that would be $0.00 each. Link to comment https://forums.phpfreaks.com/topic/204768-code-producing-error-message-and-i-cant-figure-out-why/#findComment-1072036 Share on other sites More sharing options...
Zagga Posted June 14, 2010 Share Posted June 14, 2010 It looks like this page isn't getting any variables POSTed to it. Are you sure the page that is sending the variables is using $_POST and not $_GET? Zagga Link to comment https://forums.phpfreaks.com/topic/204768-code-producing-error-message-and-i-cant-figure-out-why/#findComment-1072086 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.