Fatal Error: custom_code.php (20)

sean.regehr 22 Jan, 2020
I am experiencing a very strange problem on a form that has been working for some time without issue. The issue was first made known today and I have spent several hours debugging and verifying its execution. The issue being that on form submission the processing is not completing.

I have a multi-page form for Drop In Registration. There are several program choices, but this issue is only a problem when selecting one of the programs. After going through the intermediary pages and attempting to submit the form, this Fatal Error is displayed.

This is private content


Curious as to why this problem was being thrown I did a dump using var_dump(); and output the $content from the above script. I also turned on error reporting to maximum temporarily to make sure I was seeing everything.

As soon as I made these changes and retested, I expected to see whatever code was throwing the Fatal Error. Instead no Fatal Error was thrown and the form submitted as expected. "Good. Problem solved or so I thought."

I then reverted the changes and error reporting and retested the form expecting it work successfully again. Back came the Fatal Error.

I should mention no recent changes have been made.

The problem seems to stem from the execution of the above script. Can you please help identify how to solve this problem? (This is a time sensitive issue as classes and registration are ongoing.) If you require more details please let me know and I will do my best to provide them as I am able.
GreyHead 24 Jan, 2020
Hi Sean,

I'm confused - is there some PHP there? All I see is a message saying I'm not authorised?

Bob
sean.regehr 24 Jan, 2020
Bob,

I used the Private Content Section to hide the path. I will just obscure it instead then.
Catchable fatal error: Object of class GCore\Extensions\Chronoforms\Libs\Form could not be converted to string in ../public_html/administrator/components/com_chronoforms5/chronoforms/actions/custom_code/custom_code.php(20) : eval()'d code on line 12
The issue is that this is only triggered when a specific Program is selected, otherwise it works without any error. The same Custom Code is executing when other Programs are selected. Also when I output the $content from the above script and turned error reporting to Maximum, the issue was never flagged at all for the specific Program selection. To me it seems like the correct type is not being recognized when executing in the above script.
sean.regehr 24 Jan, 2020
I thought this might be helpful. This is the code from the var_dump on $content. I added a show stopper so I could catch the output.
string(1401) "data["program"] == 'yoga') { $form->data["program"] = "Yoga - Adults"; $form->data["total_price"] = number_format((float)15, 2, '.', ''); } else if ($form->data["program"] == 'suzuki_music') { if ($form->data["suzuki_age"] == '0_36_months') { $$form->data["program"] = "Suzuki Music 0-36 Months"; $form->data["total_price"] = number_format((float)20, 2, '.', ''); } else if ($form->data["suzuki_age"] == '3_5_years') { $form->data["program"] = "Suzuki Music Age 3-5"; $form->data["total_price"] = number_format((float)20, 2, '.', ''); } } else if ($form->data["program"] == 'language_class') { if ($form->data["language_type"] == 'french') { $form->data["program"] = "French Language Class"; $form->data["total_price"] = number_format((float)20, 2, '.', ''); } else if ($form->data["language_type"] == 'spanish') { $form->data["program"] = "Spanish Language Class"; $form->data["total_price"] = number_format((float)20, 2, '.', ''); } } function Clear_Fields () { unset($form->data["suzuki_age"]); unset($form->data["suzuki_drop_in_date"]); unset($form->data["suzuki_0_36m_time"]); unset($form->data["suzuki_3_5y_time"]); unset($form->data["language_class_type"]); unset($form->data["language_class_drop_in_date"]); } Clear_Fields(); $form->data["payment_status"] = ''; ?>" 
Two things I noticed are a) the $content is in fact a type of string and b) this portion of code is being truncated at the beginning slightly and I am at a loss as to why exactly.

This is the full code block in question from the form:
<?php

if ($form->data["program"] == 'yoga') {

$form->data["program"] = "Yoga - Adults";
$form->data["total_price"] = number_format((float)15, 2, '.', '');

} else if ($form->data["program"] == 'suzuki_music') {

if ($form->data["suzuki_age"] == '0_36_months') {

$$form->data["program"] = "Suzuki Music 0-36 Months";
$form->data["total_price"] = number_format((float)20, 2, '.', '');

} else if ($form->data["suzuki_age"] == '3_5_years') {

$form->data["program"] = "Suzuki Music Age 3-5";
$form->data["total_price"] = number_format((float)20, 2, '.', '');

}

} else if ($form->data["program"] == 'language_class') {

if ($form->data["language_type"] == 'french') {

$form->data["program"] = "French Language Class";
$form->data["total_price"] = number_format((float)20, 2, '.', '');

} else if ($form->data["language_type"] == 'spanish') {

$form->data["program"] = "Spanish Language Class";
$form->data["total_price"] = number_format((float)20, 2, '.', '');

}

}

function Clear_Fields () {

unset($form->data["suzuki_age"]);
unset($form->data["suzuki_drop_in_date"]);
unset($form->data["suzuki_0_36m_time"]);
unset($form->data["suzuki_3_5y_time"]);
unset($form->data["language_class_type"]);
unset($form->data["language_class_drop_in_date"]);

}

Clear_Fields();

$form->data["payment_status"] = '';

?>
GreyHead 25 Jan, 2020
Hi Sean,

There is an extra $ in this line $$form->data["program"] = "Suzuki Music 0-36 Months"; I don't think that is intended, please see if it is causing the problem.

Bob

PS I don't know why I can't see the Private Content - I used to be able to.
sean.regehr 27 Jan, 2020
Thanks Bob. That did the trick.

I copied my code into an editor to attempt and find any parse errors but this one was not flagged.

I appreciate the the help.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger