I'm trying to get my computed field to add up a bunch of fields in other nodes, which are nodereferrers to the "total" node. When I put this code in a computed field, I get the following error:

Invalid argument supplied for foreach() in /var/www/testsite1/sites/all/modules/contrib/computed_field/computed_field.module(161) : eval()'d code on line 3.

However, when I put the same code in the content template (contemplate module), and just "print" the $ticketcost, it works great. Any ideas?
Here's the code:

$mcs = $node->field_ticketexpenses[0]['items'];
$ticketcost = 0;
foreach($mcs as $key => $value){
$mc = 0;
$mcnid = $value['nid'];
$mc = db_result(db_query("SELECT field_cost_value FROM content_field_cost WHERE nid=" . $mcnid));
$ticketcost = $ticketcost + $mc;
}

$node_field[0]['value'] = $ticketcost;

Comments

mmjvb’s picture

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