drisate Posted August 11, 2008 Share Posted August 11, 2008 Hi guys. I am trying to build a script that updates the users account balance after a paiement is made but for some reason it's not working well. Current user balance: -53.88 ($amt) Paiement is 53.88 ($alertpay_data[16]) The balance should be 0 ... ($amts) -53.88+53.88=0 But for some reason is says the new balance is 53.88 with out any - in front so i asum it became a positive value ... Weird. I don't get it. $UPDATE = mysql_query("UPDATE atransaction SET end_date='$end_date', amt_paid='$alertpay_data[16]', end_stamp='$end_stamp', status='2', alertpay='$alertpay' where id_membre = '$transaction_data[1]' and id='$transaction_data[$theloop]'"); $amt = sprintf("%01.2f", @current(@mysql_fetch_assoc(@mysql_query("SELECT amt_bank FROM customers_info where customers_info_id='$transaction_data[1]'")))); $amts= sprintf("%01.2f", ($amt)+$alertpay_data[16]); $UPDATE = mysql_query("UPDATE customers_info SET amt_bank='$amts' where customers_info_id = '$transaction_data[1]'"); Quote Link to comment https://forums.phpfreaks.com/topic/119165-negative-not-working/ Share on other sites More sharing options...
revraz Posted August 11, 2008 Share Posted August 11, 2008 echo the following to troubleshoot: $amt $amts $alertpay_data[16] also, why do you have ( ) around $amt? probably should put it around the equation. $amts= sprintf("%01.2f", ($amt+$alertpay_data[16])); Quote Link to comment https://forums.phpfreaks.com/topic/119165-negative-not-working/#findComment-613651 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.