ipwnzphp Posted July 28, 2008 Share Posted July 28, 2008 $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 More sharing options...
cooldude832 Posted July 28, 2008 Share Posted July 28, 2008 http://us.php.net/manual/en/function.time.php probably will explain things. Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602015 Share on other sites More sharing options...
ipwnzphp Posted July 28, 2008 Author Share Posted July 28, 2008 what dose time half to do with math? Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602016 Share on other sites More sharing options...
cooldude832 Posted July 28, 2008 Share Posted July 28, 2008 time = unix time stamp = a number not what u think it is probably Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602050 Share on other sites More sharing options...
ipwnzphp Posted July 28, 2008 Author Share Posted July 28, 2008 umm? could you show some code? Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602053 Share on other sites More sharing options...
MasterACE14 Posted July 28, 2008 Share Posted July 28, 2008 the time() function, returns the seconds since some date a long time ago. I think it was January 1st, 1960, or something like that. Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602063 Share on other sites More sharing options...
ipwnzphp Posted July 28, 2008 Author Share Posted July 28, 2008 but im not dealing with dates here im dealing with $$$ Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602067 Share on other sites More sharing options...
cooldude832 Posted July 28, 2008 Share Posted July 28, 2008 http://en.wikipedia.org/wiki/Unix_epoch Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602068 Share on other sites More sharing options...
cooldude832 Posted July 28, 2008 Share Posted July 28, 2008 well you have the line setcookie("vouch_price", $amount, time()+(60*60*24*5), "/", ""); but I see that is setting a cookie length time Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602069 Share on other sites More sharing options...
ipwnzphp Posted July 28, 2008 Author Share Posted July 28, 2008 i am setting the $$ in the cookie Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602070 Share on other sites More sharing options...
trq Posted July 28, 2008 Share Posted July 28, 2008 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? Sorry, but none of that makes any sense. Your problem is actually? Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602076 Share on other sites More sharing options...
ipwnzphp Posted July 28, 2008 Author Share Posted July 28, 2008 $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. Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602081 Share on other sites More sharing options...
DarkWater Posted July 28, 2008 Share Posted July 28, 2008 Doesn't that mean it's working? O_O Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602116 Share on other sites More sharing options...
ipwnzphp Posted July 28, 2008 Author Share Posted July 28, 2008 it dosent work right Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602117 Share on other sites More sharing options...
trq Posted July 28, 2008 Share Posted July 28, 2008 it dosent work right 155 less 35 equals 120. Its pretty simple. Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602120 Share on other sites More sharing options...
ipwnzphp Posted July 28, 2008 Author Share Posted July 28, 2008 yea i know that but it should say 0.00 this is a gift card coupon Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602121 Share on other sites More sharing options...
trq Posted July 28, 2008 Share Posted July 28, 2008 Your not making sense. Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602124 Share on other sites More sharing options...
Barand Posted July 28, 2008 Share Posted July 28, 2008 Having set a cookie value, the value of that cookie is not available until the the next page load. Link to comment https://forums.phpfreaks.com/topic/117047-math-not-working-right/#findComment-602128 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.