My computed code is:
$node_field[0]['value'] = $node->field_ask[0]['value'] / db_result(db_query("SELECT field_units_value FROM content_type_deal_apt WHERE nid=%d",$node->field_ask_ref_deal[0][nid]));

It works on some content perfectly. On other content, I get zero with this in the log:
Division by zero in /var/www/drupal-sites/all/modules/computed_field/computed_field.module(138) : eval()'d code on line 1.

Any suggestions on tracking this down?

Comments

Navid19’s picture

I'm receiving the same error. I'm able to still add the content but am a little worried the content is not being added correctly.

Any advice is much appreciated.

Thanks!

Parse error: syntax error, unexpected ')' in /home/...../public_html/sites/all/modules/computed_field/computed_field.module(161) : eval()'d code on line 1

johnthomas00’s picture

It has been a few months now. My current code for this problem loads a referenced node then runs the calculation. This code has been working perfeclty for some time now.

$jtnid = $node->field_ask_ref_deal[0]['nid'];
$jtnode = node_load($jtnid);
$node_field[0]['value'] = $node->field_ask[0]['value'] / $jtnode->field_calcit_jt[0]['value'];
excaliburst’s picture

I think it must have something to do with the field types that you use for the calculation in the computed field.

I have one type of content, where divide two integers with no problem.

But then when same calculation in another content type is being done with dividing an integer with a floating point number - I get the above error too.

Any thoughts on mixing field-types in a calculation for computed field?

Best regards

Morten E

mmjvb’s picture

Issue summary: View changes
Status: Active » Closed (outdated)