When voting using Vote Up/Down widget got this error:

* user warning: Column count doesn't match value count at row 1 query: INSERT INTO votingapi_cache (vote_cache_id, content_type, content_id, value, value_type, tag, function, timestamp) VALUES (1217, 'node', 21, -0,36363636363636, 'points', 'lista', 'average', 1207388853) in /includes/database.mysql.inc on line 172.
* user warning: Column count doesn't match value count at row 1 query: INSERT INTO votingapi_cache (vote_cache_id, content_type, content_id, value, value_type, tag, function, timestamp) VALUES (1220, 'node', 21, -0,36363636363636, 'points', 'lista', 'average', 1207388854) in /includes/database.mysql.inc on line 172.

I think this is result of inserting decimal number in query: -0,3... . Semicolon in that number cause query crash due to column count mismatch.

Comments

Greggus’s picture

I've changed query in function votingapi_insert_cache_result from

db_query("INSERT INTO {votingapi_cache} (vote_cache_id, content_type, content_id, value, value_type, tag, function, timestamp) VALUES (%d, '%s', %d, %f, '%s', '%s', '%s', %d)", 
    $vobj->vote_cache_id, $vobj->content_type, $vobj->content_id, $vobj->value, $vobj->value_type, $vobj->tag, $vobj->function, $vobj->timestamp);

to:

db_query("INSERT INTO {votingapi_cache} (vote_cache_id, content_type, content_id, value, value_type, tag, function, timestamp) VALUES (%d, '%s', %d, '%f', '%s', '%s', '%s', %d)", 
    $vobj->vote_cache_id, $vobj->content_type, $vobj->content_id, $vobj->value, $vobj->value_type, $vobj->tag, $vobj->function, $vobj->timestamp);

( %f → '%f' )

and everything looks to be fine but I'm not sure if it is correct.
Can somebody tell me if it is OK to insert number value as text (in ' ')?

eaton’s picture

Status: Active » Postponed (maintainer needs more info)

Hmmm. It appears, actually, that the problem is in a localized number (-0,36363636363636) being inserted into the SQL. The comma in that is treated as a column delimiter. Are you using localized number formats on your server, by any chance?

Greggus’s picture

Yes, my server uses localized system but this error doesn't appear anymore... :)

ij3net’s picture

Version: 5.x-1.5 » 6.x-2.1
Status: Postponed (maintainer needs more info) » Active

When cast vote get a warning -
* user warning: Column count doesn't match value count at row 1 query: INSERT INTO votingapi_cache (content_type, content_id, value, value_type, tag, function, timestamp) VALUES ('node', 55, 68,5714285714, 'percent', 'vote', 'average', 1247495719) in /var/www/virtual/night.lg.ua/htdocs/includes/common.inc on line 3422.
Error in votingapi.module -

/** 
 * Save a bundle of vote results to the database. 
--cut--
 */ 
function votingapi_add_results($vote_results = array()) { 
  if (!empty($vote_results['content_id'])) { 
    $vote_results = array($vote_results); 
  } 
 
  foreach ($vote_results as $vote_result) { 
    $vote_result['timestamp'] = time(); 
    $vote_result['value']=str_replace(',','.',$vote_result['value']);
    drupal_write_record('votingapi_cache', $vote_result); 
  } 
} 

im correct it -

/** 
 * Save a bundle of vote results to the database. 
--cut--
 */ 
function votingapi_add_results($vote_results = array()) { 
  if (!empty($vote_results['content_id'])) { 
    $vote_results = array($vote_results); 
  } 
 
  foreach ($vote_results as $vote_result) { 
    $vote_result['timestamp'] = time(); 
    $vote_result['value']=str_replace(',','.',$vote_result['value']);
    drupal_write_record('votingapi_cache', $vote_result); 
  } 
} 

im add a string of code $vote_result['value']=str_replace(',','.',$vote_result['value']);

Error caused by a peculiarity of the Russian locale. In the Russian locale for the fractional part separated by a comma, not point.

legolasbo’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Drupal 6 is no longer supported. Closing old issues to clean up the issue queue.

Please reopen and update this issue if this is still an issue in the D7 or D8 version.