Jump to content

[SOLVED] only calculate before the comma


nitation

Recommended Posts

Hello people,

 

I am having problems with the comma sign in the amount field. I have a figure in my amount field that looks like this;

 

7500004

 

when i try to transfer a sum that looks like 750,0004, it will only calculate all the figures before the comma.

 

I wanna know if i have an error in my database or what.

 

my table looks like this

 

amount varchar(255);

 

do i need to change the column type to something like FLOAT, DECIMAL or what.

 

Thanks in advance

Link to comment
Share on other sites

I would assume that the file referred to by the action property of that form would have an SQL string that enters the number into the database. If you can find that and post it (or just the code for the referred page) I could see if something needs to be changed.

Link to comment
Share on other sites

This is the sql query to insert to the database

 

include ("db.php");
$sqlsub=mysql_query("insert into account_activity(userid,AccountSelector,amount_to_send)values('$afso_userid','$AccountSelector','$amount')");

 

Do i need to provide anything else?

Link to comment
Share on other sites

Just try this and see if it gives you an error in regards to what the problem is.

 

$query = "INSERT INTO `account_activity` ( `userid`, `AccountSelector`, `amount_to_send` ) VALUES ( ' $afso_userid', '$AccountSelector', '$ammount' )";
$result = mysql_query($query) or trigger_error(mysql_error());

Link to comment
Share on other sites

Well it looks like there are single quotes which would make me think that the calculations are being done in php but the number isn't being converted from a string. You might be able to fix it where the calculation is, but the best way would probably be to just remove the commas before putting the string in the database. I think this would work:

$sqlsub=mysql_query("insert into account_activity(userid,AccountSelector,amount_to_send)values('$afso_userid','$AccountSelector','".preg_replace(",", "", $amount)."')");

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.