I'm adding a record which contains a price, £9.50, and it's being rounded up/down?
I have a simple insert record 开发者_Python百科to add an item to a recordset. The data field for price is set to decimal and when the price field is sent e.g. 9.50 it appears in the database as 9.00. Why?
Here's the code from the php insert statement
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO buying (`user`, items, price) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['user'], "text"),
GetSQLValueString($_POST['items'], "int"),
GetSQLValueString($_POST['price'], "int"));
From the manual:
The declaration syntax for a
DECIMAL
column isDECIMAL(M,D)
.
So, what did you specify for D
? Sounds like perhaps 0
.
Edit
I don't know what GetSQLValueString
is, but you wrote GetSQLValueString($_POST['items'], "int")
which seems to imply that you're creating an integer, no?
If it's this function, I think you clearly meant GetSQLValueString($_POST['items'], "double")
.
精彩评论