When I submit a user location that is in the 59.xxxx 10.xxxx (this is the Oslo region - all users are there) then it ends up in the location table as 59.000000, 10.000000

In the _gmap_location_store_location function - the $object->gmap_location_latitude and $object->gmap_location_longitude are correct - with all decimals present (the .xxxxxxx) - so I can't see why the save of new or update of existing call to db_query is nulling them. After all - they are set as %f fields - isn't that correct?

Am very confused - would love a hint as to what may be wrong.

I can manually set the location fields to the correct value in the database and then they are shown correctly in the map views - so the database accepts these values itself.

Comments

chrissearle’s picture

Devel module shows the following update being called:

UPDATE location SET latitude='59,9292590183', longitude='10,7346725464', source='1' WHERE eid='4' AND type='user'

The - in MySQL client - select * from location where eid=4 and type='user' gives:

+-----+-----+------+------+--------+------------+------+----------+-------------+---------+-----------+-----------+--------+------------+
| eid | lid | type | name | street | additional | city | province | postal_code | country | latitude  | longitude | source | is_primary |
+-----+-----+------+------+--------+------------+------+----------+-------------+---------+-----------+-----------+--------+------------+
|   4 |  85 | user | NULL | NULL   | NULL       | NULL | NULL     | NULL        | NULL    | 59.000000 | 10.000000 |      1 |          0 | 
+-----+-----+------+------+--------+------------+------+----------+-------------+---------+-----------+-----------+--------+------------+

So - I paste in the update call to the mysql client, run it and then run the select again and no change.

But - if I change the , (comma) to . (dot) in both long/lat values it works.

Oddly - the submitted page had . (dot).

So - the question becomes - what changes the . (dot) to , (comma) at submit?

bdragon’s picture

European number format?

chrissearle’s picture

Where would that be set? Database is set to unicode_generic.

The site I have where this is drupal 5 does not have this issue - same database encoding. So - a PHP setting? A drupal setting?

chrissearle’s picture

sry - for unicode_generic read utf8 general for the collation name.

bdragon’s picture

Locale setting.

What does the following print out?

print_r(localeconv());
chrissearle’s picture

Array
(
    [decimal_point] => .
    [thousands_sep] => 
    [int_curr_symbol] => 
    [currency_symbol] => 
    [mon_decimal_point] => 
    [mon_thousands_sep] => 
    [positive_sign] => 
    [negative_sign] => 
    [int_frac_digits] => 127
    [frac_digits] => 127
    [p_cs_precedes] => 127
    [p_sep_by_space] => 127
    [n_cs_precedes] => 127
    [n_sep_by_space] => 127
    [p_sign_posn] => 127
    [n_sign_posn] => 127
    [grouping] => Array
        (
        )

    [mon_grouping] => Array
        (
        )

)

This was taken using the devel execute php block - hope that's OK.

bdragon’s picture

Status: Active » Postponed (maintainer needs more info)

possibly not... devel.module at at least one point in its life has set the locale to C (according to a grep of the repository), which may be masking the issue.

DGvNp0niToyRspXaaqx3PiQBMn66QXyAq5yrNHpz’s picture

I'm having this same issue. I am attempting to save form data containing decimal information. However, it is not saving the decimal into the database. It saves the 2 decimal places as .00

This is the form field I am attempting to save:

     $form[$clean_name]['market'] = array(
       '#type'					=> 'textfield',
       '#title'					=> $state_name . ' Market Share',
       '#field_suffix'	=> '%',
       '#default_value'	=> interactive_map_detail_form_default_market($maps->tid,$state_id),
     );

This is the submit function I am using:

 function interactive_map_details_edit_form_submit($form, &$form_state) {
   $vocabulary = '3';
   $state_id   = arg(5);
   $state_name = db_result(db_query("SELECT name FROM {term_data} WHERE vid = '%d' AND tid = '%d'", $vocabulary, $state_id));
   
   $select_maps = db_query("SELECT m.tid FROM {map_settings} m, {term_data} d WHERE d.tid = m.tid ORDER BY d.name ASC");
   while ($maps = db_fetch_object($select_maps)) {
     $term_name  = db_result(db_query("SELECT d.name FROM {map_settings} m, {term_data} d WHERE d.tid = '%d' AND d.tid = m.tid", $maps->tid));
     $clean_name = str_replace(" ", "_", strtolower($term_name));

     db_query("UPDATE {map_status} SET status = '%d', market_share = '%d', regulations = '%s' WHERE state_id = '%d' AND term_id = '%d'", $form_state['values'][$clean_name]['status'], $form_state['values'][$clean_name]['market'], $form_state['values'][$clean_name]['details'], $state_id, $maps->tid);
   }

   interactive_map_build_xml();
   drupal_set_message(t('The map details for <em>' . $state_name . '</em> have been saved.'));
 }

This is the database settings I am using:
field: market_share
type: decimal
length: 3,2

This is the print out of my locale settings (NOT through Devel):

Array
(
    [decimal_point] => .
    [thousands_sep] => 
    [int_curr_symbol] => 
    [currency_symbol] => 
    [mon_decimal_point] => 
    [mon_thousands_sep] => 
    [positive_sign] => 
    [negative_sign] => 
    [int_frac_digits] => 127
    [frac_digits] => 127
    [p_cs_precedes] => 127
    [p_sep_by_space] => 127
    [n_cs_precedes] => 127
    [n_sep_by_space] => 127
    [p_sign_posn] => 127
    [n_sign_posn] => 127
    [grouping] => Array
        (
        )

    [mon_grouping] => Array
        (
        )

)

Any ideas on solving this are greatly appreciated.

Thanks,

Josh

bdragon’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Josh, YOUR issue is that you're using %d when you mean %f. Also you have a bunch of spurious single quotes in your queries. Please read the documentation for db_query carefully.

As for the original issue, I'm assuming it was a locale related problem.

Closing.