Tuesday, 3 May 2016

mysqli - PHP Fatal error: Call to a member function bind_param() on a non-object

The bind_param that is failing is this




$stmt->bind_param('ssss', $this->template->forms->reg_username, $this->template->forms->reg_password, $this->template->forms->reg_email, "Test");





the prepared statement is




$stmt = $this->mysqli->prepare("INSERT INTO 'users' (username, password, email, referr) VALUES (?, ?, ?, ?)");




The whole Register function is




public function Register() {

unset($this->template->forms->error);
$this->template->forms->setData();

if(isset($this->template->forms->submit)) {

if(!isset($this->template->forms->reg_username)) {
$this->template->forms->error = "You must enter an username";
}


if(!isset($this->template->forms->reg_password)) {
$this->template->forms->error = "You must enter a password";
}

if(!isset($this->template->forms->reg_password_confirm)) {
$this->template->forms->error = "You must confirm your password";
}

if(!isset($this->template->forms->reg_email)) {

$this->template->forms->error = "You must enter an email address";
}

if($this->template->forms->reg_password != $this->template->forms->reg_password_confirm) {
$this->template->forms->error = "Your passwords must match";
} else if(strlen($this->template->forms->reg_password) <= 5) {
$this->template->forms->error = "Your password must be 6 characters or more.";
}

if(!$this->template->forms->error) {

$stmt = $this->mysqli->prepare("INSERT INTO 'users' (username, password, email, referr) VALUES (?, ?, ?, ?)");
$stmt->bind_param('ssss', $this->template->forms->reg_username, $this->template->forms->reg_password, $this->template->forms->reg_email, "Adam");
$stmt->execute();
}

}
}

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...