SchweppesAle Posted May 5, 2010 Share Posted May 5, 2010 Hi, whenever I try inserting a float value of 1,226.37 into a Decimal(10,2) table column; all I see is 1. Is there a reason why this happens? Thanks Link to comment https://forums.phpfreaks.com/topic/200828-inserting-float-value-of-122637-into-decimal102-table-column/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 5, 2010 Share Posted May 5, 2010 That's because a 1000's comma is a human convention to make a number more human readable. It has no meaning to a computer and in fact most computer programs stop parsing numbers at the first non-number, which is why you are only getting a 1. You need to remove any commas from numbers. str_replace would probably be the quickest function to use - http://us3.php.net/manual/en/function.str-replace.php Link to comment https://forums.phpfreaks.com/topic/200828-inserting-float-value-of-122637-into-decimal102-table-column/#findComment-1053788 Share on other sites More sharing options...
SchweppesAle Posted May 5, 2010 Author Share Posted May 5, 2010 You're absolutely right. I just picked that up a few minutes ago. I hadn't realized that the value being returned by another function was actually a string and not a float value. Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/200828-inserting-float-value-of-122637-into-decimal102-table-column/#findComment-1053800 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.