title: PHP Fatal error: Call to a member function bind_param() on a non-object
body: <p>The bind_param that is failing is this</p>
  
  <blockquote>
    <p>$stmt->bind_param('ssss', $this->template->forms->reg_username, $this->template->forms->reg_password, $this->template->forms->reg_email, "Test"); </p>
  </blockquote>
  
  <p>the prepared statement is</p>
  
  <blockquote>
    <p>$stmt = $this->mysqli->prepare("INSERT INTO 'users' (username, password, email, referr) VALUES (?, ?, ?, ?)");</p>
  </blockquote>
  
  <p>The whole Register function is</p>
  
  <pre><code>public function Register() {
  
      unset($this-&gt;template-&gt;forms-&gt;error);
      $this-&gt;template-&gt;forms-&gt;setData();
  
      if(isset($this-&gt;template-&gt;forms-&gt;submit)) {
  
          if(!isset($this-&gt;template-&gt;forms-&gt;reg_username)) {
              $this-&gt;template-&gt;forms-&gt;error = "You must enter an username";
          }
  
          if(!isset($this-&gt;template-&gt;forms-&gt;reg_password)) {
              $this-&gt;template-&gt;forms-&gt;error = "You must enter a password";
          }
  
          if(!isset($this-&gt;template-&gt;forms-&gt;reg_password_confirm)) {
              $this-&gt;template-&gt;forms-&gt;error = "You must confirm your password";
          }
  
          if(!isset($this-&gt;template-&gt;forms-&gt;reg_email)) {
              $this-&gt;template-&gt;forms-&gt;error = "You must enter an email address";
          }
  
          if($this-&gt;template-&gt;forms-&gt;reg_password != $this-&gt;template-&gt;forms-&gt;reg_password_confirm) {
              $this-&gt;template-&gt;forms-&gt;error = "Your passwords must match";
          } else if(strlen($this-&gt;template-&gt;forms-&gt;reg_password) &lt;= 5) {
              $this-&gt;template-&gt;forms-&gt;error = "Your password must be 6 characters or more.";
          }
  
          if(!$this-&gt;template-&gt;forms-&gt;error) {
              $stmt = $this-&gt;mysqli-&gt;prepare("INSERT INTO 'users' (username, password, email, referr) VALUES (?, ?, ?, ?)");
              $stmt-&gt;bind_param('ssss', $this-&gt;template-&gt;forms-&gt;reg_username, $this-&gt;template-&gt;forms-&gt;reg_password, $this-&gt;template-&gt;forms-&gt;reg_email, "Adam");
              $stmt-&gt;execute();
          }
  
      }
  }
  </code></pre>