I am using the Computed Field module to find the total ounces of fish caught on a tournament results content page I created.

The formula is (Weight Lbs * 16) + Weight Oz = Total Ounces

The PHP code I am using is -

$node_field[0]['value'] = ($node->field_weightlbs[0]['value']) * 16 + ($node->field_weightoz[0]['value']);

When I go to enter the results and hit submit I get the following two error messages:

Parse error: syntax error, unexpected '<' in /home4/xxx/public_html/xxx/modules/computed_field/computed_field.module(161) : eval()'d code on line 1

Parse error: syntax error, unexpected '<' in /home4/xxx/public_html/xxx/modules/computed_field/computed_field.module(299) : eval()'d code on line 1

Is this an error with my PHP code, settings, module or something else? Thank you for your help.

Comments

allnet000’s picture

I should also note that the Weight Lbs and Weight Oz fields are being entered in by the user/admin.

technotim2010’s picture

This error only occurred when I migrated my site to the production server on a shared host.

The computed code is
$node_field[0]['value'] = $node->field_last_pat_test_date[0]['value'] + (365 * 24 * 60 * 60);

On my Dev Ubuntu box I had no issues at all. On the Production server I get the parse error all the time, not on every page but enough to remove the node type using computed field and also disable the module.

Now since Chris http://drupal.org/node/1114872 and I both get the same error on different sites with different hosts but the same php version running on each 5.2.17 and different code in their computed fields this clearly points to one of two things:

Either the code for Computed field is written to be wholly compliant with PHP 5.3 and above (I run 5.3.3 on my dev box) but 5.2.17 on the production host (both chris above and I have the same php versions on the production hosts and no way to change that) or running the computed field exposes some flaw in 5.2.17 which was not apparant or vice versa before the sites were migrated and computed field used.

Is anyone else having this issue or is it just us? and does anyone have any idea of a fix.

Regards

Tim