Hi. I am using the following code to store some floats. Anyone got any ideas why the db would store them as ints? The table rows are floats, I did check that...

function currtable_insert_currency($cur){
	if (!($gbprate = currtable_get_conversion('GBP',$cur))) $gbprate = 0;
	if (!($eurrate = currtable_get_conversion('EUR',$cur))) $eurrate = 0;
	if (!($usdrate = currtable_get_conversion('USD',$cur))) $usdrate = 0;
	db_query("INSERT INTO {currtable} (ctid,ctgbprate,cteurrate,ctusdrate) VALUES ('%s',%f,%f,%f)",$cur,$gbprate,$eurrate,$usdrate);
	drupal_set_message('New currency inserted: '.$cur.', GBP rate = '.$gbprate.', EUR rate = '.$eurrate.', USD rate = '.$usdrate);
}

That drupal_set_message outputs floats, so go figure.

Please help.

Comments

Anonymous’s picture

Status: Active » Fixed

Never mind. I'm an idiot, had the same table updating using %d in another place...

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.