我有以下代码:
// write new users data into database
$query_new_user_insert = $this->db_connection->prepare('INSERT INTO users (user_name, user_password_hash, user_email, user_activation_hash, user_registration_ip, user_registration_datetime) VALUES(:user_name, :user_password_hash, :user_email, :user_activation_hash, :user_registration_ip, now())');
$query_new_user_insert->bindValue(':user_name', $user_name, PDO::PARAM_STR);
$query_new_user_insert->bindValue(':user_password_hash', $user_password_hash, PDO::PARAM_STR);
$query_new_user_insert->bindValue(':user_email', $user_email, PDO::PARAM_STR);
$query_new_user_insert->bindValue(':user_activation_hash', $user_activation_hash, PDO::PARAM_STR);
$query_new_user_insert->bindValue(':user_registration_ip', $_SERVER["HTTP_CF_CONNECTING_IP"], PDO::PARAM_STR);
$query_new_user_insert->execute();
error_log( "Hello, errors!");
error_log($query_new_user_insert->error);
// id of new user
$user_id = $this->db_connection->lastInsertId();
if ($query_new_user_insert) {
$this->messages[] = MESSAGE_REGISTRATION_ACTIVATION_SUCCESSFUL;
$this->registration_successful = true;
} else {
$this->errors[] = MESSAGE_REGISTRATION_FAILED;
}
没有报告错误,但没有新行添加到mysql中 PHP报告已启用且error_log仅显示(Hello,errors!)
编辑:重复的帖子回答问题。绑定值为null