title: Mysqli update throwing Call to a member function bind_param() error
body: <p>I have a 70/80 field form that I need to insert into a table so instead of manually creating one huge insert statement I firstly have created a table in my db from the names of the inputs in the form here is the code that I use to create/alter the table</p>
  
  <pre><code>function createTable($array, $memberMysqli)
  {
     foreach ($array as $key =&gt; $value)
     {
              //echo "&lt;p&gt;Key: ".$key." =&gt; Value: ".$value . "&lt;/p&gt;";
              $query = "ALTER TABLE questionnaire ADD ".$key."  text";
  
              if($stmt = $memberMysqli-&gt;prepare($query))
              {
                  $success = $stmt-&gt;execute();
              }
     }
           echo "&lt;h1&gt;Array count: ". count($array) ."&lt;/h1&gt;" ;
  }
  </code></pre>
  
  <p>This works fine and altered the table exactly how I wanted it. Now to insert the form values to do this I do a basic one field insert store the id of the row and then have loop all the post variables updating that row. Here is my code for that:</p>
  
  <pre><code>$stmt = $memberMysqli-&gt;prepare("INSERT INTO questionnaire(userid) VALUES (?)");
  
  $stmt-&gt;bind_param('s', $_POST['userid']);
  $stmt-&gt;execute();
  $rowid = $stmt-&gt;insert_id;
  $stmt-&gt;close();
  
  $memberMysqli-&gt;autocommit(FALSE);
  
  function updateColumn($memberMysqli, $query, $uid, $value) 
  {
      if ($value) 
      {
          $stmt = $memberMysqli-&gt;prepare($query);
          //Throws bind param error here
          $stmt-&gt;bind_param("ss", $value, $uid);
          $stmt-&gt;execute();
      }
  }
  
  function loopInputs($array, $memberMysqli, $rowid)
  {
       foreach ($array as $key =&gt; $formvalue)
       {
          var_dump($key);
          updateColumn($memberMysqli, "UPDATE questionnaire SET $key = ? WHERE id = ?", $rowid, $formvalue);
       }
  }
  
  loopInputs($_POST, $memberMysqli, $rowid);
  
  $memberMysqli-&gt;commit();
  $memberMysqli-&gt;close();
  </code></pre>
  
  <p>This throws a bind param error and I have no idea why.</p>