title: How to bind paramater from binded result in while stmt
body: <p>I want to bind the result from prepared query which is in while stmt. But it gives me the error</p>
  
  <blockquote>
    <p>Call to a member function bind_param</p>
  </blockquote>
  
  <p>We all know this obvious error message... I just don't know why is this error popping out...</p>
  
  <p>Here is my php code (session is started and all rows and columns are correct)</p>
  
  <pre><code>$selectposts = "SELECT postby,posttxt,time,upvotes,downvotes FROM posts ORDER BY id DESC";
  $stmt = $mysqli-&gt;prepare($selectposts);
  $stmt-&gt;execute();
  $stmt-&gt;bind_result($postby,$posttxt,$posttime,$upvotes,$downvotes);
  while($stmt-&gt;fetch()){
     $picturestmt = $mysqli-&gt;prepare("SELECT picture FROM members WHERE username = ?");
          $picturestmt-&gt;bind_param('s', $postby);
          $picturestmt-&gt;execute();
          $picturestmt-&gt;bind_result($picture);
                          while($picturestmt-&gt;fetch()){
                                  if(empty($picture)){
                                          $profpicturefromdb = " &lt;img src='profile_pictures/public_icon.png' width='25' height='25' class='fxdmimg'&gt;";
                                  } else {
                                          $profpicturefromdb = " &lt;img width='25' class='fxdmimg' height='25' src='profile_pictures/".$picture."' alt='Profile Picture'&gt;";
                                  }
                          }
  }
  </code></pre>
  
  <p>This code should assign the $profpicturefromdb to an image. (And also pull out all posts from database but that's another echo)</p>
  
  <p>If I echo the $postby, it shows the name of user who posted the post. That's fine, but why it does not assign that to the <code>"bind_param('s',$postby');</code> ?
  Thanks</p>