I have found several reports of this message being associated with PHP 5.5 and 'empty()' and also containing the word 'function' in place of 'method' but they don't seem related to my instance. My code:

  $query = ($db->getQuery(true));
   $query->select ($db->quoteName('name'))
    ->from ($db->quoteName('#__users'))
    ->where (
        select ($db->quoteName('field_value'))
            -> from ($db->quoteName('#__osmembership_field_value'))
            -> where ($db->quoteName('field_id') = 30)
            -> where ($db->quoteName('subscriber_id') = $subscription_id)

throws this error on the line "where ($db->quoteName('field_id') = 30)". I tried both with the double 'where' statements and with AND but both gave the error even when testing on https://phpcodechecker.com/ - so nothing to do with Joomla but hoping someone who knows the JDatabase syntax can help. I have Joomla 5.1 with PHP 8.1.

  • You can turn on Debugging and Error Reporting in your Global Configuration to provide more details as to exactly where and which piece of code is failing and post the extra information into your question.
    – Irata
    Commented Jul 3 at 1:53

3 Answers 3


The problematic lines need to be changed to use concatenation so the equals sign becomes part of the resulting string and not an assignment operator in PHP:

-> where ($db->quoteName('field_id') . ' = ' . 30)
-> where ($db->quoteName('subscriber_id') . ' = ' . $subscription_id)

You have an invalid & incomplete syntax for a nested Joomla query within a Where function of a parent query thus what is being returned to the first Where function is not valid and hence you are getting this error. The obvious thing is you are missing a definition of $query2 and then in your nested Query you aren't specifying to use that second query, $query2, so I can't really guess at what sort of property is being return or what query Joomla is trying to build.

This update of your code isn't intended to suggest it will work but merely to try and show how you have missed a fundamental aspect of building a sub-query. I also removed the extra spaces to follow a more conventional style of coding.

  $query  = $db->getQuery(true);
  $query2 = $db->getQuery(true);
            ->where($db->quoteName('field_id') = 30)
            ->where($db->quoteName('subscriber_id') = $subscription_id)

You really should read up on creating sub-query's in Joomla to get a better understanding of why your approach is not working and how it could or should be coded.

Two sources I used to learn Joomla sub-queries are this post in github, https://gist.github.com/gunjanpatel/8663333, and this collection of Joomla Stack Exchange questions and answers, https://joomla.stackexchange.com/search?q=%24subquery

  • Thank you Irata. I am new to JDatabase and this looks like a great help - lots to learn yet!
    – OOC
    Commented Jul 3 at 17:54
  • The answer from @Sharky appears to be the correct answer that specifically solves the error message you are receiving and if you implement his changes and it moves you beyond the error then please accept his answer as the correct one so future researchers with the same message can see this has been solved.
    – Irata
    Commented Jul 3 at 22:24
  • Thank you @Sharky - the syntax correction helps and also the info on where to find out more about JDatabase.
    – OOC
    Commented Jul 4 at 15:56
  • OOC, on Joomla Stack Exchange when someone provides an answer that solves your issue then the process/etiquette is that you should Accept that answer by clicking on the grey Tick icon next to their answer on the left. Points are attributed to the person who posted the answer and in the list displays of questions your question will show an 'answer' icon with a solid green background that indicates to other people the issue has been resolved. In the future somebody searching for the same message then is more likely to choose your question because it shows that the answer solved your issue.
    – Irata
    Commented Jul 5 at 7:43
  • OOC, My answer is not the correct answer, you should be Accepting @Sharky's answer as the message was generate by the incorrect syntax identified by Sharky. My answer might have been useful to you but didn't directly identify the cause of the error message. People with the same error message the find this question in the future should see the correct answer as accepted.
    – Irata
    Commented Jul 6 at 23:50
  • As already cited, you have syntax errors in your coding attempt.
  • Dropping a subquery directly into a WHERE clause looks like it would be better written as a JOIN (and may well be optimised by your database to be a JOIN anyhow).
  • All of those quoteName() calls are unnecessary because there are no MYSQL reserved words to explicitly quote.

I assume your intended query could be better scripted as:

$query = $db->getQuery(true);
      ->from('#__users AS u')
      ->join('INNER', '#__osmembership_field_value AS fv ON u.id = fv.subscriber_id')
      ->where('fv.field_id = 30')
      ->where('fv.subscriber_id = :subscription_id')
      ->bind(':subscription_id', $subscription_id);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.