title: Error accessing MySQL database with PHP object (nested queries)
body: <p>I want to get some data from a Sphinx server and pass it to MySQL to execute some queries. I'm new to PHP so probably I'm missing something here. I've looked for <a href="https://stackoverflow.com/questions/18136762/php-sql-query-inside-another-querys-fetch-statement">similar</a> <a href="https://www.tonymarston.net/php-mysql/databaseobjects.html" rel="nofollow noreferrer">questions</a> but can't find anything so maybe you can help me.</p>
  
  <p>The error is in the first <code>while</code>. I'm pretty sure it's due to the <code>$rown</code> variable but don't know the reason. (I've verified that I can retrieve data from the connections so it is passing the data where the error lies - could be the sql syntax of the query but that seems fine).</p>
  
  <p><strong>Edited</strong> the code thanks to the comments below, now I get the error: <code>Warning: mysqli_fetch_object() expects parameter 1 to be mysqli_result, boolean given in C:\Apache24\htdocs\test3.php on line 20</code>. This is because the query failed, I still suspect it is because <code>$rown</code>.</p>
  
  <pre><code>$sphinxcon  = mysqli_connect...
  $mysqlcon   = mysqli_connect...
  
  $query      = "SELECT names FROM iproducts LIMIT 0,1000";
  $raw_results= mysqli_query($sphinxcon, $query);
  
  //Until here works ok, now I want to pass $raw_results to MySQL
  
  while ($row = mysqli_fetch_object($raw_results)) {
      $rown = $row-&gt;names;
      $mquery = "SELECT text FROM claims WHERE EXISTS ($rown) LIMIT 0,1000"; 
  
      $mysqlresults = mysqli_query($mysqlcon, $mquery);
  
      while ($final = mysqli_fetch_object($mysqlresults)) //this is line 20
      {
          printf ("%s&lt;br /&gt;", $final-&gt;text);
      }
  
  }
  </code></pre>
  
  <p>Thanks :)</p>