Jump to content

PHP & Mysql weirdness


knoob

Recommended Posts

Hi everyone!

 

Have a weird problem which I've been troubling for some time just not sure what I'm missing.

 

SQL statement created by PHP looks like this:

 

insert into PerformanceBalance (id_tmp,item,Value1,Value2,Value3,Value4) values ('1','name','2213.54','194.2','68.5','828.95');

 

While inserting it to Mysql DB through commandline all the values goes correctly to the database but if insert if done via PHP:

 

$result = @mysql_db_query("DB1", $sql);

 

The Value1 is incorrect in DB:

 

| id_tmp  | item    | Value1    | Value2    | Value3    | Value4 |

+----------+----------+------------+-----------+------------+--------+

| 1 | name | 2.000000 | 194.200000 | 68.500000 | 828.950000 | 125.700000 |

 

 

Fields in the DB all are the same:

 

+----------------------------+---------------+------+-----+---------+-------+

| Field                      | Type          | Null | Key | Default | Extra |

+----------------------------+---------------+------+-----+---------+-------+

| id_tmp                    | char(15)      | NO  | PRI | NULL    |      |

| item                      | char(15)      | NO  | PRI | NULL    |      |

| Value1                    | decimal(15,6) | YES  |    | NULL    |      |

| Value2                    | decimal(15,6) | YES  |    | NULL    |      |

| Value3                    | decimal(15,6) | YES  |    | NULL    |      |

| Value4                    | decimal(15,6) | YES  |    | NULL    |      |

 

 

It does not matter if I change the order for the insert line for Values, still it's always 'Value1' which is inserted incorrectly.

 

Updating the DB works fine, just cannot figure out the problem in PHP's behavior or if it's the problem at all.

 

Does anyone have any idea?

 

PHP version is 5.3.3

Mysql version 5.1.49

 

Using Ubuntu 10.10

 

Link to comment
Share on other sites

Hmm, both getting me something to think about. Indeed now can see the error:

 

MySQL error 1366: Incorrect decimal value

 

Though changing the presentation to 2,213.54 didn't solve it, could be a setting somewhere but still would like to handle the numbers as pure decimals.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.