Skip Navigation

[Resolved] Calculator parse error

This support ticket is created 8 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by jonathanB-13 8 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#350389

I am trying to:
In template:
<td>[wpv-calculate][types field="odds"]*[types field="units"][/wpv-calculate]</td>

Added to functions:
add_shortcode('wpv-calculate', 'calculate_shortcode');
function calculate_shortcode($atts,$content=null) {
$content = wpv_do_shortcode($content);
$content = eval("return $content;"); (this is line 364)
return $content = number_format($content,2);
}

I visited this URL:

I expected to see: The calculation works, but I get a Parse error. If I change to field+field the unexpected is [

Instead, I got: Parse error: syntax error, unexpected '*' in /var/sites/o/oddsspill.com/public_html/wp-content/themes/grafika/functions.php(364) : eval()'d code on line 1

#350453

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Could you please try to use following code:

add_shortcode('wpv-calculate', 'calculate_shortcode');
function calculate_shortcode($atts,$content=null) {
$content = wpv_do_shortcode($content);
$content = eval('return ' . $content . ';');
return $content ;
}

More important thing is that you will need check if the php function eval() is supported in your web server.
hidden link

#350468

Exactly same error, my host says the function is supported..
"You are able to use all parts of the php code."

#350473

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What if you remove that line and use following shortcode. Does you get desired output?

add_shortcode('wpv-calculate', 'calculate_shortcode');
function calculate_shortcode($atts,$content=null) {
$content = wpv_do_shortcode($content);

return $content ;
}

#350476

I found the problem, in one of the post I did not fill inn the custom fields, so that made the calclutaion display only a *
When I filled out these it worked, I have to make conditonil display then, so if the custom fields is not filled in it will not display, that I can manage 🙂

Thanks!

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.