Q:

Fatal error: Call to a member function bind_param() on boolean in php while inputing String from Android app

 public function StoreUserInfo($sid, $name, $email, $password, $ktp, $gender) {
    $hash = $this->hashFunction($password);
    $encrypted_password = $hash["encrypted"];
    $salt = $hash["salt"];

    $stmt = $this->conn->prepare("UPDATE user SET name = $name , email = $email , encrypted_password = $encrypted_password , salt = $salt, ktp = $ktp , gender = $gender WHERE sid = '$sid'");
    $stmt->bind_param("sssssss", $sid, $name, $email, $encrypted_password, $salt, $ktp, $gender);
    $result = $stmt->execute();
    $stmt->close();

    if ($result) {
        $stmt = $this->conn->prepare("SELECT name, email, encrypted_password, salt, ktp, gender FROM user WHERE sid = $sid");
        $stmt->bind_param("s", $sid);
        if ($stmt === FALSE) {
        die($mysqli->error);}
        $stmt->execute();
        $stmt-> bind_result($token1,$token2,$token3,$token4,$token5,$token6,$token7);
        while ( $stmt-> fetch() ) {
           $user["sid"] = $token1;
           $user["name"] = $token2;
           $user["email"] = $token3;
           $user["ktp"] = $token6;
           $user["gender"] = $token7;
        }
        $stmt->close();
        return $user;
    } else {
        $response["error"] = TRUE;
        $response["error_msg"] = "Unknown error occurred in input!";
        echo json_encode($response);
      return false;
    }
}

I have this code and error shows

Fatal error: Call to a member function bind_param() on boolean in line 7

do I should not use prepare() on UPDATE ?
but when I remove it, it shows same error in line 13
then I need bind_param() right ? 
what should I do ?
by the way my input updated in table, but i want to check it and return it true.

A:

You're using prepare / bind the wrong way...
The mysqli_ nameless version :
$stmt = $this->conn->prepare('UPDATE user 
    SET name = ?, 
        email = ? , 
        encrypted_password = ? , 
        salt = ?, 
        ktp = ?, 
        gender = ? 
    WHERE sid =?');

  $stmt->bind_param("sssssss", 
        $name, 
        $email, 
        $encrypted_password, 
        $salt, 
        $ktp, 
        $gender,
        $sid
        );

  $result = $stmt->execute();

The PDO one :
$stmt = $this->conn->prepare('UPDATE user 
    SET name = :name, 
        email = :email , 
        encrypted_password = :encrypted_password , 
        salt = :salt, 
        ktp = :ktp, 
        gender = :gender 
    WHERE sid =:sid');
// $stmt->bind_param("sssssss", $sid, $name, $email, $encrypted_password, $salt, $ktp, $gender);
$result = $stmt->execute(array(
        ':name'=>$name, 
        ':email'=>$email, 
        ':encrypted_password'=>$encrypted_password, 
        ':salt'=>$salt, 
        ':ktp'=>$ktp, 
        ':gender'=>$gender,
        ':sid'=>$sid,
        )
    );

