Jump to content

Negative not working?


drisate

Recommended Posts

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]'");

Link to comment
Share on other sites

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]));

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.