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 8782999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:42:53+00:00 2026-06-13T20:42:53+00:00

I am inserting decimals into my MYSQL database but the values that end up

  • 0

I am inserting decimals into my MYSQL database but the values that end up in the DB are rounded, despite my having set the DB to DECIMAL(10,4). For example I set the discount to 6.5 and the DB records it as 7.

My query is:

$save = sprintf("
INSERT INTO discount
SET         am_discount = %d,
                tx_discount = '%s'
",
    $_POST['am_discount'],
    mysql_escape_string($_POST['tx_discount'])
);

I’ve tried setting the am_discount field to %u and %f as well, but it doesn’t seem to make a difference.

As I mentioned, the am_discount field in my MYSQL DB is set to DECIMAL (10,4) and I’ve also tried (10,2) and (8,2).

What am I missing?

  • 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-13T20:42:55+00:00Added an answer on June 13, 2026 at 8:42 pm

    Try :

    $save = sprintf("INSERT INTO discount  SET am_discount = '".$_POST['am_discount']."',
                    tx_discount = '".mysql_escape_string($_POST['tx_discount'])."' ");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My (MySQL) tables have columns with currency values set as Decimal(10,2) with decimals separated
When inserting a row in mysql database, string values need to be enclosed in
Inserting multilingual data into a SQL 2008 database (nvarchar field) I notice that it
When inserting an object into a database with SQLAlchemy, all it's properties that correspond
We are inserting values into a SQL Server 2005 database column of type NUMERIC(19,5)
I'm writing a routine that validates data before inserting it into a database, and
I am having issues inserting this into my database I think tis when I
I have a table with two decimal(18,0) fields. I am inserting into this table,
While inserting rows into SQL Server CE in WP7 I'm getting a SQLCeException that
When inserting a new user into a database i want to hash the password.

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.