scottdg 0 Posted September 17, 2011 Report Share Posted September 17, 2011 "Parse error: syntax error, unexpected $end in C:\xampp\htdocs\handle_calc.php on line 51" I checked the code from top to bottom 3 times so if there is a problem I am just having a hard time seeing it. Here is the code as I typed it. I appreciate any assistance you could offer. Thanks. <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Product Cost Calculator</title> <style type="text/css" media="screen"> .number { font-weight: bold; } </style> </head> <body> <?php // Script 4.2 - handle_calc.php /*This script takes values from calculator.html and performs total cost and monthly payment calculations.*/ //Address error handling, if you want. //Get the values from the $_POST array: $price = $_POST['price']; $quantity = $_POST['quantity']; $discount = $_POST['discount']; $tax = $_POST['tax']; $shipping = $_POST['shipping']; $payments = $_POST['payments']; //Calculate the total: $total = $price * $quantity; $total = $total + $shipping; $total = $total - $discount; //Determine the tax rate $taxrate = $tax/100; $taxrate = $taxrate + 1; //Factor in the tax rate: $total = $total * $taxrate; //Calculate the monthly payments: $monthly = $total / $payments; //Print out the results: print "<p>You have selected to purchase:<br /> <span class=\"number\">$quantity</span> widget(s) at <br /> $<span class=\"number\">$price</span> price each plus a <br /> $<span class=\"number\">$shipping</span> shipping cost and a <br /> <span class=\"number\">$tax</span> percent tax rate.<br /> After your $<span class=\"number\">$discount</span> discount, the total cost is $<span class=\"number\">$total</span>.<br /> Divided over <span class=\"number\"> $payments</span> monthly payments, that would be $<span class=\"number\">$monthly</span> each.</p>"; ?> </body> </html> Quote Link to post Share on other sites
Jonathon 255 Posted September 17, 2011 Report Share Posted September 17, 2011 I just copied this code and ran it ok, obviously I just put in fixed values in place of the $_POST. $end is often a case of omitting a ; or } Quote Link to post Share on other sites
scottdg 0 Posted September 17, 2011 Author Report Share Posted September 17, 2011 So where could the problem be then? I read that is usually the meaning of that error but nothing seems to be missing. Quote Link to post Share on other sites
Lou 3 Posted September 18, 2011 Report Share Posted September 18, 2011 Works fine on my end. The code you posted on the forum does not create a parse error. Quote Link to post Share on other sites
Lou 3 Posted September 18, 2011 Report Share Posted September 18, 2011 You should download and use Netbeans, it will inform you of a missing semicolon or unmatched braces. What IDE do you use to write your code? Quote Link to post Share on other sites
Lou 3 Posted September 18, 2011 Report Share Posted September 18, 2011 Make sure your DOCTYPE is in caps, too. You had it in lowercase. Quote Link to post Share on other sites
scottdg 0 Posted September 18, 2011 Author Report Share Posted September 18, 2011 I'll fix the doctype. I am using crimson editor right now. Quote Link to post Share on other sites
Larry 433 Posted September 20, 2011 Report Share Posted September 20, 2011 Which line is line 51? And what version of PHP are you using? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.