Error when accessing form via menu

Status
Not open for further replies.

fudge4u

Member
Here is an error I am getting:

0 - syntax error, unexpected ';'

I have a menu set up to display a specific form. When I click the menu in PHP 5.6, it works fine. When I switch to PHP 7, I get the error as soon as I click the menu item. My other forms in the database work fine when accessing them by a menu with any PHP version. It's just this one form and only with PHP 7.

J!3.8.2, Fabrik 3.8 Any thoughts?
 
I don't think this is a systemic issue in Fabrik, or other people would be reporting it, and I've never seen this error before.

Do you have any of your own custom code anywhere on that form, like in calc elements, or PHP plugins, etc?

-- hugh
 
No custom code on the form, but several calc elements to lookup joined data. The elements have code like this:

$ret = '';
$db = JFactory::getDBO();
$query = "SELECT item_description FROM new_mcdc_items WHERE item_name = " . $db->Quote('{new_mcdc_orders___item_to_order}');
$db->setQuery($query);
$ret = $db->loadResult();
return $ret;
 
Have you checked all the calcs? If you temporarily unpublish all the calcs, does it still error out?

-- hugh
 
Thank You - I narrowed it down to a single element - a price lookup from a table based on the selection in the form. I have 2 other calc elements which work fine. The code in the element is:

$ret = '';
$qty={new_mcdc_orders___quantity_to_order};
$db = JFactory::getDBO();
$query = "SELECT price
FROM new_mcdc_quantities
WHERE item = '{new_mcdc_orders___item_to_order_raw}' AND quantity = $qty";
$db->setQuery($query);
$ret = $db->loadResult();
return $ret;

I experimented some and changed the code to the following: (basically getting rid of the $qty placeholder variable and inserting that element name directly in line 6 above)

$ret = '';
$db = JFactory::getDBO();
$query = "SELECT price
FROM new_mcdc_quantities
WHERE item = '{new_mcdc_orders___item_to_order_raw}' AND quantity = '{new_mcdc_orders___quantity_to_order}'";
$db->setQuery($query);
$ret = $db->loadResult();
return $ret;

And now it works in PHP 7. Thanks again for your suggestion to check the calc elements!

Don
 
Pretty sure the problem was
$qty={new_mcdc_orders___quantity_to_order};
You must always quote placeholders in php, otherwise you'll get exactly your error if the field is empty.
So
$qty='{new_mcdc_orders___quantity_to_order}';
 
I checked out that suggestion. I also had to quote the variable $qty in the line:
WHERE item = '{new_mcdc_orders___item_to_order_raw}' AND quantity = '$qty'";

With both those changes, it also functions in PHP 7. I'm glad I was able to solve it now before the Joomla! 4.0 release next year, which will require PHP 7.

Thanks again!

......closing thread
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top