Please help with this value pickup code

How to fix a ChronoForms value pickup code that fails to output a dynamic price.

Overview

The issue occurs when using complex variable syntax inside curly braces in PHP, which prevents the code from executing correctly.
Simplify the code by keeping only the variable name inside the curly braces and construct the dynamic key separately before using it.

Answered
Ro Ron 17 Aug, 2014
Hello

I am not able to make this code work:

< ?php echo "\n         {$prices['frt_'.$form->data['currency'].'_afkv']}"; ? >


I want to add the [currency] in place of "afkv" the output would be : frt_9_3

9 = USD
3 = device 1

Thanks

Ron
Ro Ron 17 Aug, 2014
sorry not [currency] it is [device]
Ro Ron 17 Aug, 2014
Hi,

I have tried this code but I cannot find the error as it does not work:

< ?php 
$price_string = $form->data['frt'].'_'.$form->data['currency'].'_'.$form->data['device'];
$freight_value += "\n         {$prices[$price_string]}"; 
?>


Thanks

Ron
Ro Ron 18 Aug, 2014
Answer
I have been able to solve it.

Thanks
Gr GreyHead 18 Aug, 2014
Hi Ronn,

We can't provide a free service for debugging user's bad PHP :-(

But - in this case the {$variable} syntax will not work if you add a string inside the {} - keep it just to the variable name.

Bob
Ro Ron 18 Aug, 2014
Thanks for that advice Bob.

I will keep it in mind.

Best wishes

Ronn
This topic is locked and no more replies can be posted.