I can’t seem to make this work. I’m trying to update my password in PHP, but it keeps throwing me an error. This is what it keeps saying.
Fatal error: Call to a member function bind_param() on a non-object in /update_password.php on line 29
It keeps point to the same line and I keep trying to modify it, but it just keeps throwing the same thing over and over. The table exists, the records exist, the column “password” exists, the column “email” exists, I just can’t put my mind on what’s going on.
Here’s the portion of the code that it keeps pointing to.
class mysqliSingleton {
private static $instance;
private $db_connection;
private function __construct() {
$this->db_connection = new mysqli(MYSQLI_HOST, MYSQLI_USERNAME, MYSQLI_PASSWORD, MYSQLI_DATABASE);
if($this->db_connection->connect_errno) {
echo "Error, failed to connect to MySQL database. Please fix.";
exit();
}
}
public static function init() {
if(is_null(self::$instance)) {
self::$instance = new mysqliSingleton();
}
return self::$instance;
}
public function __call($name, $args) {
if(method_exists($this->db_connection, $name)) {
return call_user_func_array(array($this->db_connection, $name), $args);
} else {
trigger_error('Unknown Method ' . $name . '()', E_USER_WARNING);
return false;
}
}
}
class Website_Connection {
protected $CONNECTION;
public function __construct() {
$this->CONNECTION = mysqliSingleton::init();
}
}
The connection works. I’ve tested it via other templates. The only part that it doesn’t work is just the updating password. I’ve used the same method to login and it works. I strip the usersalt and $_POST[‘password’], then I bind them both together. Tried it with the login template. Works fine.
Only thing is, that was because all I was doing was selecting the data, but once I update the data, it doesn’t update.