I am new to coding. Currently trying to setup registration form. I seached for the answer, as I saw maybe binding parameters before execute() will work. However, I have no idea how to do it. Please help. The code below shows following error:
Fatal error: Uncaught Error: Call to a member function execute() on boolean in C:\xampp\htdocs\kibble\php-user-registration-form\DataSource.php:99 Stack trace: #0 C:\xampp\htdocs\kibble\php-user-registration-form\Member.php(83): Phppot\DataSource->insert('INSERT INTO reg...', 'ssss', Array) #1 C:\xampp\htdocs\kibble\php-user-registration-form\index.php(20): Phppot\Member->insertMemberRecord('lalafasdf123', 'Moka24', '123123123123', 'localoca@gmail....') #2 {main} thrown in C:\xampp\htdocs\kibble\php-user-registration-form\DataSource.php on line 99
public function insert($query, $paramType, $paramArray)
{
print $query;
$stmt = $this->conn->prepare($query);
$this->bindQueryParams($stmt, $paramType, $paramArray);
$stmt->execute();
$insertId = $stmt->insert_id;
return $insertId;
}
insert function if needed
function insertMemberRecord($username, $displayName, $password, $email)
{
$passwordHash = md5($password);
$query = "INSERT INTO registered_users (user_name, display_name, password, email) VALUES (?, ?, ?, ?)";
$paramType = "ssss";
$paramArray = array(
$username,
$displayName,
$passwordHash,
$email
);
$insertId = $this->ds->insert($query, $paramType, $paramArray);
return $insertId;
}