title: Function not working: PHP Fatal error: Call to a member function bind_param() on boolean
body: <p>Here is my function, i've sat here for a good while trying to figure out what is not working, it says its on the line where $stmt2->bind_param:</p>
  
  <pre><code>function addDailyTickets() {
      global $mysqli,$db_table_prefix;
  
      $stmt = $mysqli-&gt;prepare("SELECT 
          id
          FROM ".$db_table_prefix."users 
          WHERE active=1
          ");
  
      $stmt-&gt;execute();
      $stmt-&gt;bind_result($id);
  
      while ($stmt-&gt;fetch()){
          $created_timestamp = time();
          $status = "active";
          $transaction_id = "daily_".date('n-j-Y');
          $game_id = 0;
          $ticket_uniqID = uniqid("tick_");
  
          $stmt2 = $mysqli-&gt;prepare("INSERT INTO ".$db_table_prefix."tickets (
          user_id,
          created_timestamp,
          status,
          transaction_id,
          game_id,
          ticket_uniqID
          )
          VALUES (
          ?,
          ?,
          ?,
          ?,
          ?,
          ?
          )");
          $stmt2-&gt;bind_param("iissis", $id, $created_timestamp, $status, $transaction_id, $game_id, $ticket_uniqID);
          $stmt2-&gt;execute();
      }
      $stmt-&gt;close();
      $stmt2-&gt;close();    
  }
  </code></pre>
  
  <p>If i put a $stmt2->error_list; right before the $stmt2->bind_param, it returns with no errors.</p>
  
  <p>phpMyAdmin:
  <a href="https://i.stack.imgur.com/xKqIo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xKqIo.png" alt="phpMyAdmin"></a></p>