title: Object of class mysqli could not be converted to string
body: <p>I am getting this error from the following code:</p>
  
  <pre><code>function updateRank($master_list, $event_id)
  {
      $cnt_ml =  count($master_list);
      echo "count master list = $cnt_ml&lt;br&gt;";
  
      $b=1;
  
      for ($k=0; $k&lt;$cnt_ml; $k++)
      {
          echo "master list element 1 - ".$master_list[1]."&lt;br&gt;";
          $foo = $master_list[$k];
  
          // Update each team in event_team table             
          $update = "UPDATE event_team 
                    SET pool_rank = $b 
                    WHERE event_id = $event_id
                    AND team_id = $foo";
  
          mysqli_query($conn, $update);// or die ('Could not run insert in event_team table');
  
  
  
          echo "|".$update."|&lt;br&gt;";   // Leave this line for debugging the sql query.
          $b++;
      }   
  }
  </code></pre>
  
  <p>Specifically "$foo" is throwing the error. The "master_list" array is being passed correctly. When running the code, $cnt_ml returns "5" (which is absolutely correct). The line with:</p>
  
  <pre><code>echo "master list element 1 - ".$master_list[1]."&lt;br&gt;";
  </code></pre>
  
  <p>Returns "54" (which is correct). </p>
  
  <p>Since the script is successfully able to read the array elements and post them, why is the script throwing the error when I include it in the UPDATE? It is able to see the array data but choking when trying to use the data in the UPDATE. </p>
  
  <p>Thanks in advance!</p>