By PaulWood on
This isn't really a Drupal issue as it may be a MySQL issue:
I am adding a record to a MySQL table using the following code:
db_query(
"INSERT INTO {sl_guests}(uid, nid, model, s_nid, s_model, qty, phone, altphone, email, txt_msg, signupdate, fee, status)
VALUES (%d, %d, '%s', %d, '%s', %d, '%s', '%s', '%s', '%s', %d, %d, '%s')",
$user->uid,
$thisnode,
$thismodel,
$shadow_nid,
$thismodel."~SE",
$nonmbrqty,
$me->profile_phone,
$me->profile_altphone,
$user->mail,
$me->profile_txt_msg,
time(),
$node->list_price,
t('In checkout')
);
When I insert a value for $node->list_price of $1.50 it gets stored in the database as $1.00. Values in even dollar increments, such as $25.00 are stored correctly. Looks to me like some rounding might be going on, but I can't figure out where. The field type for 'fee' is Decimal 10,2. Any thoughts on what might be going on or how to correct it?
Comments
You are use an integer modifier
What happens if you change the last %d to %f ?
see:
http://api.drupal.org/api/function/db_query/6
http://api.drupal.org/api/function/_db_query_callback/6
--
Anton
Anton, Duh! Of course.
Anton,
Duh! Of course. That took care of it.
Thanks for pointing out to me what should have been obvious. I appreciate it.
-Paul