SOLVED - Changing to latest PHP results in "syntax error, unexpected ';'"

Status
Not open for further replies.

nclaypool

Member
So I'm finally able to transition from the very old 5.4 PHP version we were using since I got rid of some dated plugins. I select the latest recommended by our hosting company of 7.1 but upon doing so, when I go to add records to two of our most commonly used (and thus complicated) forms, right when I click Add I get the error "0 syntax error, unexpected ';'"

Now I know my PHP skills are crummy so I immediately assumed this was some custom code I've got in one of my elements or forms. So I went through element-by-element, unpublishing one at a time, testing the form again, then moving onto the next one. Did the same with the form plugins. So far turning off any one of those hasn't resulted in a different outcome.

I tried using Fabrik's debug mode but it doesn't really give me details as to where the failure is occurring as far as I can tell.

Does anyone have any suggestions for tracking down where this problem is at seeing as the error message the server is spitting out is less than useful?

Any guidance would be greatly appreciated.
 
1. Which Fabrik and Joomla version?
2. Enable Joomla's "Debug System" (in Global Config/System). This will show you the call stack and may give a hint.
 
I have updated my signature accordingly, always forget about that.
I am running 3.9.12 of Joomla and 3.9 of Fabrik.

I did as you suggested and turned on Joomla's debugging which did at least indicate that it was a calc element that was to blame, not many of those on these forms so I quickly discovered the problematic element. When I turn on "Only calculate on Save" it lets the form load but fails with the same error upon saving.

The code on this item is incredibly simple and I'm not seeing any semicolons where there shouldn't be. I ran the code through a PHP checker and it didn't like the first line stating that the bracket around purchase_orders___id is invalid but from what I see in the documentation this is still the preferred way to call out an element to be used within the calc process. Do you see anything amiss here?

PHP:
$po_id = {purchase_orders___id};

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
  ->select('ext_price')
  ->from('purchase_orders_30_repeat')
  ->where('parent_id = ' . $po_id);
 
$db->setQuery($query);
$all_ext_price = $db->loadColumn();

$subtotal = array_sum($all_ext_price);
$grand_total = $subtotal + '{purchase_orders___additional_fees}';

return $grand_total;
 
Yup, that first line should have quotes around the placeholder.

Code:
$po_id = '{purchase_orders___id}';

Notice that you do use quotes on your $grand_total line, for the additional_fees.

-- hugh
 
Ah, thank you so much, I stared at that for a long time and that never jumped out at me.

That was all it took, once I added those quotes around those items the error disappeared. Thank you so much again.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top