delz wrote:

> Hi All,
> 
> How do I make calculations in php or mysql if the value has a comma like
> 2,000 + 32,000 = 34,000. I have a problem
> calculating if one of my values has a comma. It doesn't display the right
> output. I'll appreciate anyone who can
> help me with this.
> 
> Thanks.
> 
> Delz.


Hi Delz


Are you out by an order of magnitude?  I don't know where abouts in the 
world you are, but whereas US/UK/AUS uses the comma as a thousands 
separator and the full stop/period as a decimal separator, in Europe, 
the reverse is true.

I just did a test, inserting the value 1,000 into a float field.  I 
pulled that value out again and it was 1.  Repeated the test with a dot 
instead - same result!

So, I would advise:
1)  Only store numbers in suitable numeric fields (not varchar/char).
2)  Get rid of *all* numeric punctuation before inserting it into a 
database.  Example in Perl:
$mynumber =~ s/.//g; $mynumber =~ s/,//g;


Cheers

M

-- 
Matthew Smith           |   _     ASCII Ribbon Campaign
IT Consultant           |  ( )  - No HTML/RTF in e-mail
Kadina, South Australia |   X   - No Microsoft docs in e-mail
http://www.kbc.net.au   |  / \  - No vCards
Ph: +61 888 212 395     |


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to