hi,
i’m new to php however, when i output the contents of a variable using echo “”.$variablename; it displays zero in the result. Have changed this to $_POST[“variablename”]; however, still displays a zero. I know that there is data in the calculation of the variable but not sure as to why it displays the contents as 0. Have apache, php and mysql correctly installed. Phpinfo displays correctly with all the variables. register_globals variable is set to off. however, this should not be an issue. Am running php version 5.2.4. Below is the program code:
echo “
Your order is as follows:”; //F is yr in 4 digit format.
echo “
”;
echo $_POST[“tireqty”]." tires
“; // These variables display the data contents correctly.
echo $_POST[“oilqty”].” bottles of oil
“;
echo $_POST[“sparkqty”].” spark plugs
“;
$totalqty =0;
$totalamount=0.00;
$totalqty = $tireqty + $oilqty + $sparkqty;
define(“TIREPRICE”,100);
define(“OILPRICE”,10);
define(“SPARKPRICE”,4);
$totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE;
$totalamount = number_format($totalamount, 2);
echo “Items Ordered: “.$totalqty.”
\n”; //----------> The variable $totalqty is showing as 0
echo “Subtotal: $”.$totalamount.”
\n"; //------> The variable $totalamount is showing as $0.00
$taxrate = 0.10; //local sales tax is 10%
$totalamount = $totalamount * (1 + $taxrate);
$totalamount = number_format($totalamount, 2);
echo “Total including Tax: $” .$totalamount. “
\n”; //-------->The variable $totalamount is showing as $0.00
output of program shows:
Order processed at 18:40, 27th September
Your order is as follows:
2 tires
4 bottles of oil
3 spark plugs
Items Ordered: 0
Subtotal: $0.00
Total including Tax: $0.00