I have a small problem. I have an input box on one page that posts a number into an int table/row in a mysql database. But if i for instance enter 0,50 the number becomes 0 in the database.
I have tried with (int) before the variable, or intval/floatval etc, but i cannot seem to get the number correct. Please help
i want the exact number, if i enter 0,50 i want it to input 0,50
It seems it may be some conflict with the datatypes from the $_POST array and the INT datatype in the database maybe? If so, how can i make a string value to an exact decimal number?
The key here is that if the MySQL column is defined as a float or decimal type, you must use the "." (period/full stop) character as the decimal separator, not the "," (comma) in your SQL. If you want to allow the user to input numbers using the comma, then you will need to convert it to a period before using it in your query.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
In cases where the user enters something like "1234,56" that should be fine. However, what if the user enters "1,234.56" or "12,345,678" or "12.345,6". (Thus the problem with different standards around the world. )
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks