I have this problem:
Warning: #1265 Data truncated for column
I got a form with a value coming from a text field : price.
When I put a decimal like : 45,56 ( French format)
My MySQL column type is a float.
Could someone help please ?
I have this problem:
Warning: #1265 Data truncated for column
I got a form with a value coming from a text field : price.
When I put a decimal like : 45,56 ( French format)
My MySQL column type is a float.
Could someone help please ?
float data must be saved with a . "Dot" instead of a , "comma". 45.56
so before to save the data in the mysql, be sure that the format is correct.
You should not use the comma ,
as a decimal separator, but a dot .
e.g. 45.56
Not only are you getting a warning, it also doesn't save the decimals. :)
You should never use floating-point types for currency if you care about precision. You'll experience all sorts of weird rounding and comparison errors. For more information, see the Wikipedia page on Floating Point.
DECIMAL would suit your needs better -- from the MySQL documentation:
The DECIMAL and NUMERIC types [...] are used to store values for which it is important to preserve exact precision, for example with monetary data."
DECIMAL(15,2) would be a good idea, but it doesn't change that currency formatting runs foul of storing numbers -- you need to change the comma to a decimal before the value will be accepted into a column that is a numeric data type.