views:

321

answers:

3

I have this query:

UPDATE table_name 
  SET field_1 = field_1 +100,
      field_2 = field_2 +100,
      field_3 = field_3 +100
WHERE id = 1 
LIMIT 1;

Where Field_1 is regular integer, Field_2 is decimal(15,6) and Field_3 is double(15,6). When I run this query from php script they update just field_1 and nothing happen with field_2 and field_3 they just stay as before. But when I run in phpMyAdmin it's work without any problems.

I'm tried to lock tables, make round() before run update, nothing help.

Please help... why I can't update decimal and float fields from php?

PHP version: 5.2 Mysql version 5

A: 

Does it have a default value ?? if field_2 == NULL then the query won't update that field

Gabriel Poama-Neagra
field_2 Not NULL Default 0.00000000
Serhiy
A: 

One of the possible problems:

Locale. If You use non English - American locale, there is a chance, that Your numbers are interpreted incorrectly - decimal separator is not ".", but ",", just try insert "," instead of "." in Your float numbers and look what happens. If thats the case, You'll have to either write a converting function in PHP (which PHPAdmin has, thats why You don't face the problem there), or change the locale.

arunas_t
A: 

Nothing help. But I found one small solution (I want to go away from it). When I run next query like

INSERT INTO error SET error_type = ' ;

Of course this is return error but previous query with update update all fields.

Any suggestion?

Serhiy