At the the moment, I stored values in my mysql database as a decimal value (199,54).
But If I get this value with php (mysql query) and would like to calculate with it:
echo ($row->myValue) / 5;
I get the error:
A non well formed numeric value encountered ...
Where is my mistake?
2
Answers
You can use
floatval
function to convert decimal value that is fetched from database and then you can use in calculation:Now you can use
$floatValue
variable in any calculation.As others have pointed out decimal separator in php is dot (.) not comma (,).
Either change the separator on the DB level to . or run the following anytime you want to deal with numbers stored in the database. First two lines are just an example to get it running locally for me