Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9161325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:56:35+00:00 2026-06-17T13:56:35+00:00

i ran into a really strange problem with storing values in MySQL. The premise:

  • 0

i ran into a really strange problem with storing values in MySQL. The premise:

I have a table that uses DECIMAL(15,8) to store monetary values (like the total of order), but when i try to insert for example:

2,45545345

this is stored as

2.00000000

I tried MySQL’s FORMAT/CAST functions but still the same output.

This is how the query gets generated:

$db->query("INSERT INTO `random_table_name` SET currency_value = '" . floatval($value) . "'");

i also tried doubleval, but same result. The funny thing is though that this same piece of code was working fine a couple of weeks ago and i can’t recall any changes to the db structure or the db class that can cause this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:56:36+00:00Added an answer on June 17, 2026 at 1:56 pm

    Use number_format to replace the , with .

    Like this:

    number_format($value, 8, '.') // 8 = number of decimals, . = decimal separator
    

    However, your problem seems to be related to the current locale. You need to look into the following: setlocale() and localeconv

    setlocale(LC_ALL, 'en_US'); // NOT TESTED, read up on the appropriate syntax
    

    This is the appropriate way of doing this, the alternative would be (as suggested below), to do a str_replace(',', '.'), but you have to do the reverse every time you want to output strings.

    There is another option though, you can set the MySQL locale to en_US.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a really strange problem today when using the MySQL function GROUP_CONCAT
Background: I ran into a problem that I find somewhat unexpected. I have a
I ran into this problem in a Visual Basic program that uses WMI but
I ran into a weird problem today that I don't really fully understand. Hopefully
Firstly sorry, I'm a really big beginner. I ran into a problem that I
I ran into a problem that suggests I may be implementing a design pattern
I ran into a strange issue with tinyMCE that i was not able to
I have ran into a very strange issue with Google Maps in Chrome 5.0.375.99:
I ran into a little problem today when I was creating a really quick
I currently ran into a problem I can not really solve by myself: I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.