Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8659203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:57:22+00:00 2026-06-12T15:57:22+00:00

I am developing a php script within the Joomla environment which queries the same

  • 0

I am developing a php script within the Joomla environment which queries the same table / database twice. Each time I need to know whether any matches are found.

It seemed that the best way would be to use the getNumRows(). The Joomla documentation is very specific on its use:

Miscellaneous Result Set Methods getNumRows()

getNumRows() will return the number of result rows found by the last
query and waiting to be read. To get a result from getNumRows() you
have to run it after the query and before you have retrieved any
results.

I follow this in my script. At the first query there is no problem, but the second query always throws up a warning – most likely because the getNumRows() call for the second time is after the retrieving results from the first query – which does not comply with the Joomla requirement.

Any ideas how to solve? Many thanks!

The part of my script in question reads:

$db = JFactory::getDBO();
$query = "SELECT * FROM #__art_mobiles WHERE user_agent_header='$ua'";
$db->setQuery($query);
$rowsAG = $db->getNumRows();
$replyAG = $db->loadRow();

if ($rowsAG == 0) {

//if no match check www.handsetdetection.com
//see https://www.handsetdetection.com/properties/vendormodel for current list of models in database together with headers
echo "not in local database - try external<br/>";  
$prod = '';

if ($hd3->siteDetect()) {

    $replyHD = $hd3->getReply();

    $man = $replyHD['hd_specs']['general_vendor'];
    $dev = $replyHD['hd_specs']['general_model'];
    $os = $replyHD['hd_specs']['general_platform'];
    echo "found in handsetdetection.com database<br/>";

    //check for provisional match in local database
    $query = "SELECT * FROM #__art_mobiles WHERE manufacturer='$man' AND device='$dev'";
    $db->setQuery($query);
    $rowsAGprov = $db->getNumRows();
    $replyAGprov = $db->loadRow();

    if ($rowsAGprov == 0) { **[ETC]**
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:57:24+00:00Added an answer on June 12, 2026 at 3:57 pm

    I think this could be an issue with using $db->loadRow(); as getNumRows relies on an executed query.

    For example you could try:

    $db = JFactory::getDBO();
    $query = "SELECT * FROM #__art_mobiles WHERE user_agent_header='$ua'";
    $db->setQuery($query);
    $replyAG = $db->query();
    $rowsAG = $db->getNumRows();
    

    And:

    $query = "SELECT * FROM #__art_mobiles WHERE manufacturer='$man' AND device='$dev'";
    $db->setQuery($query);
    $replyAGprov = $db->query();
    $rowsAGprov = $db->getNumRows();
    

    Though I am not sure what/if the difference will be between the results returned from query and loadRow. It would be worth experimenting and seeing if this works.

    Alternately, if you are only using getNumRows to see if a record exists, you could do some kind of check on your $replyAG variable instead. It again might be worth experimenting to see what loadRow returns if there are no results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a php script which contains an html form. If not all
With PHP, I am developing a script that generates a contract once the script
Currently developing a PHP framework and have ran into my first problem. I need
Is it possible to retrieve a GET variable within a PHP script and subsequently
I am developing a PHP script that has to make some calls to a
I am developing a module which has a jQuery script with some AJAX code.
Okay, I am developing an Application which requires getting sensitive information from a database
I am developing a PHP script for uploading .PDF documents as medium BLOBs into
I'm developing a PHP script to send the content of a file from one
i have a database in MySQL who i query from a php script. Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.