I have these values which I need to save into MySQL (column DECIMAL 10, 2).
-500.00
-500.00
35000.00
When a PHP script save these values into the database and I will take a look at these saved values, there is just:
500.00
500.00
5000.00
How’s it possible?
EDIT:
Saving into DB:
mysql_query("INSERT INTO table (name, address, salary) VALUES ('$name', '$address', $salary)");
I also tried to add apostrops to the $salary, but the same thing, didn’t help me to save the correct value.
EDIT 2:
When I print out the variables with these numbers before executing the SQL query, so the values are correct. But when I print out the currently executed SQL query, there are the incorrect values…
The column definition should be
DECIMAL(10, 2)and not followed byUNSIGNED. The missing sign could be caused by an “unsigned”.The error on 35000.00 could be an output error (
sprintf).Most uniformly, you remove the first char at output.
Maybe you tried to change one ‘.’ in salary by nothing, removing the first character.