# phpMyAdmin - 2 decimal places problem



## JiminSA (Dec 15, 2011)

I have a database table containing average daily kilometerage (if such a word exists) allowed, and having been done, for, and by, cars in a rental fleet.
I have set up both fields as decimal(11,2) in the type column of the table (see attached screenshots) and have defaulted the 'allowed' field to 82.20 which shows correctly in the Structure Tab of phpMyAdmin but is rounded down to 82.00 in the Browse Tab and subsequently the database itself.
How can I insist on 2 decimal places for fields in my DB, if not by using decimal(11,2) in my Type column? I'm obviously missing something...


----------



## allnodcoms (Jun 30, 2007)

Hay Jim,

When you manually insert a record (through phpMyAdmin) does the decimal value hold? You are doing things correctly, so I'm wondering if it's the PHP that inserts the values into the DB that is causing the rounding error, rather than your table structure...

Danny


----------



## JiminSA (Dec 15, 2011)

Hi Danny
Here's the rub... I haven't inserted any data into these two brand new fields yet, either manually with admin or via php. But the phpMyAdmin has set the default field rounded down, all by it's ownsome


----------



## allnodcoms (Jun 30, 2007)

Try creating a couple of records, one with 82.21 and another with 82.95. Let me know how it turns out... Let's see if it's rounding or truncating.

Danny


----------



## JiminSA (Dec 15, 2011)

Sorry about the delay Danny (TSG Server problems)

As suggested I created and amended using admin and php and encountered no rounding problems.

It does appear that phpMyAdmin is the culprit. I wonder if I shouldn't go to their forum and report it?


----------



## NVWebsites (Oct 19, 2012)

How'd it turn out? Seems like the difference between an integer and a float data type.


----------



## JiminSA (Dec 15, 2011)

Hi and welcome NVWebsites,
It hasn't "turned out" yet - I'm waiting on a reaction from my post in the sourceforge.net phpMyAdmin forum and other sources


----------

