title: mysqli prepare - only works when not a function?
body: <p>That one always returns a false bool:</p>
  
  <pre><code>&lt;?php
  function check($username, $db_conx) {
      $sql = 'SELECT User_ID FROM tbl_user WHERE Username=?';
      $stmt = $db_conx-&gt;prepare($sql);
      $stmt-&gt;bind_param('s', $username);
      $stmt-&gt;execute();
      $ret= $stmt-&gt;get_result();
      $stmt-&gt;close();
      $db_conx-&gt;close();
      $ret = $ret-&gt;fetch_row();
      return $ret;
  }
  
  $usr = "root";
  $res = check($u,$db_conx);
  echo var_dump($res);
  echo $a[0];
  ?&gt;
  </code></pre>
  
  <p>I don't get it, they are pretty equal - so what's the error?</p>
  
  <p>That one returns what I expected:</p>
  
  <pre><code>&lt;?php
  $usr = 'root';
  $sql = "SELECT User_ID FROM tbl_user WHERE Username=?";
  $stmt = $db_conx-&gt;prepare($sql);
  $stmt-&gt;bind_param('s', $usr);
  $stmt-&gt;execute();
  $ret = $stmt-&gt;get_result();
  $stmt-&gt;close();
  $db_conx-&gt;close();
  
  $ret = $ret-&gt;fetch_row();
  echo var_dump($ret);
  echo $ret[0];
  ?&gt;
  </code></pre>
  
  <p>I want to recycle it over and over again with the function, but it doesn't seem to work. Is it even possible to set &amp; execute the parameters in a function or have I just made a stupid mistake?</p>