you can strip of comma first and then enter into the DB
Main Topics
Browse All TopicsI am having problems with entering a price into a MySQL decimal (10,2) field. If a person enters 2118.56 in the HTML form, the record enters OK. However, if they enter 2,118.56, the price field in the record is 2.00.
I am using PHP to insert the record.
Should I be using addslashes, or something else?
Thanks,
Calvin
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
i_m_aamir I agree, but if the user then does something different, like spaces in the number then you would need to do more str_replaces, if you use a regular expression then it will remove everything that is incorrect and you will not get this problem,
alternatively you could just test to see if the number fits the correct format - ie ########.## and if not then just post an error and get the user to correct it themselves.
Business Accounts
Answer for Membership
by: Raynard7Posted on 2007-03-19 at 14:55:12ID: 18752051
If you are using php then you would need to use preg_replace() in php to remove all characters that are not equal to 0-9 or . or - n/function .preg-repl ace.php
http://au.php.net/manual/e
mysql's fields will only accept plain numbers - commas are not acceptable in a numeric type