i ran into a really strange problem with storing values in MySQL. The premise:
I have a table that uses DECIMAL(15,8) to store monetary values (like the
Use number_format to replace the , with .
Like this:
number_format($value, 8, '.') // 8 = number of decimals, . = decimal separator
However, your problem seems to be related to the current locale. You need to look into the following: setlocale() and localeconv
setlocale(LC_ALL, 'en_US'); // NOT TESTED, read up on the appropriate syntax
This is the appropriate way of doing this, the alternative would be (as suggested below), to do a str_replace(',', '.'), but you have to do the reverse every time you want to output strings.
There is another option though, you can set the MySQL locale to en_US.
Replace the , with . before inserting into db:
$value = str_replace( ',', '.', $value);
This will create a valid number, that can be safely inserted into the database. Or just add it just inside your query:
INSERT INTO `random_table_name` SET currency_value = '" . str_replace( ',', '.', $value ) . "'