SirChick Posted October 23, 2007 Share Posted October 23, 2007 I have a variable set at 10,800 and im trying to subtract it in my query like here: $Price = 10,800 in this example. $subtractMoney = "UPDATE userregistration SET MoneyInHand=MoneyInHand-'$Price' WHERE UserID='{$_SESSION['Current_User']}'"; $result = mysql_query($subtractMoney) or die(mysql_error()); if (mysql_affected_rows() == 0) { die('Error ID 0001A, contact admin on the forums immediately about this error!'); } But the subtraction is only going down by 10. Not 10,800.. although this 10,800 could be any value this was what i used for this example. Quote Link to comment https://forums.phpfreaks.com/topic/74515-solved-integer-doesnt-subtract-fully/ Share on other sites More sharing options...
teng84 Posted October 23, 2007 Share Posted October 23, 2007 10,800<--- is not a number try to remove the comma Quote Link to comment https://forums.phpfreaks.com/topic/74515-solved-integer-doesnt-subtract-fully/#findComment-376595 Share on other sites More sharing options...
SirChick Posted October 23, 2007 Author Share Posted October 23, 2007 how do you do that :S whats the feature called? Quote Link to comment https://forums.phpfreaks.com/topic/74515-solved-integer-doesnt-subtract-fully/#findComment-376597 Share on other sites More sharing options...
marcus Posted October 23, 2007 Share Posted October 23, 2007 $Price = str_replace(",","",$Price); Quote Link to comment https://forums.phpfreaks.com/topic/74515-solved-integer-doesnt-subtract-fully/#findComment-376600 Share on other sites More sharing options...
SirChick Posted October 23, 2007 Author Share Posted October 23, 2007 Thanks may I ask how do you do the reverse effect ? Is it: $Price = str_replace("",",",$Price); ? Quote Link to comment https://forums.phpfreaks.com/topic/74515-solved-integer-doesnt-subtract-fully/#findComment-376601 Share on other sites More sharing options...
marcus Posted October 23, 2007 Share Posted October 23, 2007 $Price = number_format($Price); //back to normal echo number_format(10800); //10,800 Quote Link to comment https://forums.phpfreaks.com/topic/74515-solved-integer-doesnt-subtract-fully/#findComment-376602 Share on other sites More sharing options...
kenrbnsn Posted October 23, 2007 Share Posted October 23, 2007 use the function number_format() <?php $Price = 10000; $new_price = number_format($price,2); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/74515-solved-integer-doesnt-subtract-fully/#findComment-376603 Share on other sites More sharing options...
SirChick Posted October 23, 2007 Author Share Posted October 23, 2007 Thankyou! Quote Link to comment https://forums.phpfreaks.com/topic/74515-solved-integer-doesnt-subtract-fully/#findComment-376604 Share on other sites More sharing options...
teng84 Posted October 23, 2007 Share Posted October 23, 2007 ok i guess your prob is answered and i guess its done if your data types in your db is INT DOUBLE POST!! READ THE LAST POST ;D Quote Link to comment https://forums.phpfreaks.com/topic/74515-solved-integer-doesnt-subtract-fully/#findComment-376606 Share on other sites More sharing options...
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.