Division by zero in computed_field.module(138) : eval()'d code on line 1.

johnthomas00 - May 26, 2009 - 00:39
Project:Computed Field
Version:6.x-1.0-beta2
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

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?

#1

Navid19 - August 19, 2009 - 02:48

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

#2

johnthomas00 - August 19, 2009 - 03:11

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'];

#3

excaliburst - September 29, 2009 - 16:10

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

 
 

Drupal is a registered trademark of Dries Buytaert.