插入数据 PDO 的问题

Issue with inserting data PDO

我正在尝试插入用户填写的数据(注册表)我遇到了问题,它没有插入数据,同时没有给我任何错误或原因,我已经检查过我的日志和一切,似乎没有错。但是我的查询没有执行。

  /* IN THIS FUNCTION WE REGISTER THE USER, WE CREATE A SALT, INSERT THAT SALT KEY INTO SALTS TABLE, THEN GET THE ID AND USE THAT ID IN PASSYSTEM TABLE WHERE WE STORE THE PASSWORD AND THE SALT ID THE MEMBER DATA IS STORED IN MEMBERS TABLE*/
    $data = $_POST;
    print_r($data);
    $salt = $this->gen_salt();
    $password =  hash('sha512', $salt.$data['password'].$salt, FALSE);
    print $password;
      $membersql = "INSERT INTO member (`firstname`,`lastname`,`email`,`gender`) VALUES (:firstname, :lastname, :email, :gender)";
      $memberquery = $db->prepare($membersql);
      $memberquery->bindParam(':firstname', $data['firstname'], PDO::PARAM_STR);
      $memberquery->bindParam(':lastname', $data['lastname'], PDO::PARAM_STR);
      $memberquery->bindParam(':email', $data['email'], PDO::PARAM_STR);
      $memberquery->bindParam(':gender', $data['gender'], PDO::PARAM_STR);

      $memberquery->execute();

bindparam 似乎有问题。

这样试试:

$membersql = "INSERT INTO member (firstname,lastname,email,gender) VALUES (?, ?, ?, ?)";
$memberquery->execute(array($data['firstname'], $data['lastname'], $data['email'], $data['gender']));

这应该可以正常工作。