I am inserting decimals into my MYSQL database but the values that end up in the DB are rounded, despite my having set the DB to DECIMAL(10,4). For example I set the discount to 6.5 and the DB records it as 7.
My query is:
$save = sprintf("
INSERT INTO discount
SET am_discount = %d,
tx_discount = '%s'
",
$_POST['am_discount'],
mysql_escape_string($_POST['tx_discount'])
);
I’ve tried setting the am_discount field to %u and %f as well, but it doesn’t seem to make a difference.
As I mentioned, the am_discount field in my MYSQL DB is set to DECIMAL (10,4) and I’ve also tried (10,2) and (8,2).
What am I missing?
Try :