Jump to content

Math not working right.


ipwnzphp

Recommended Posts

$balanc = mysql_query("SELECT * FROM `jos_vm_vouchers` WHERE voucher_number = '$cop_code'") or die (mysql_error());
$balan = mysql_fetch_array($balanc);

$amount = $balan['voucher_value'];

setcookie("vouch_price", $amount, time()+(60*60*24*5), "/", "");

echo $_COOKIE['vouch_price'];

if (isset($_COOKIE['vouch_price'])) {
$order_total = $_COOKIE['vouch_price'] - $total;
} else {
$order_total += $shipping_total + $total;
}

 

say the cookie is 155 and the price is 35 well. the amount is coming back as 120 but it should come back as 0 why is it not working?

 

Link to comment
https://forums.phpfreaks.com/topic/117047-math-not-working-right/
Share on other sites

$amount = "155";

// Cookie = 155
setcookie("vouch_price", $amount, time()+(60*60*24*5), "/", "");

if (isset($_COOKIE['vouch_price'])) {
$order_total = $_COOKIE['vouch_price'] - $total;
} else {
$order_total += $shipping_total + $total;
}

 

the price of $total = 35 the price of the cookie = 155 now when it comes back it says 120 insted of saying 0.00 for the total of the order.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.