我已经编写了下面的查询,但没有错误,也没有更新记录 请任何人都能纠正它。
$db->query("INSERT INTO members (username, password, email)
VALUES ('$username', '$password', '$email')");
答案 0 :(得分:0)
使用PDO(php Data Object)
$db_conn = new PDO('mysql:host=localhost;dbname=account','root','password');
// insert the new member
$sql = 'INSERT INTO member (username, password, firstname, joinDate)
VALUES (:username, :password, :firstname, NOW())';
$stmt = $db_conn->prepare($sql);
// perform query
$stmt->execute(array(
':name' => 'okanlawonE12',
':password' => 'okanlawonEmmanuel',
':firstname' => 'emmanuel')
);
// echo last inserted row
echo "New Member has been added: " . $db_conn->lastInsertId();
答案 1 :(得分:0)
您的查询看起来不错,检查您的变量(用户名,密码和电子邮件)可能是空的,尝试使用 public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
{
var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
{
RequireUniqueEmail = false
};
进行检查。这个代码来自我的一个项目,我修改了变量,使其与您的变量匹配。
echo "Username: " . $username . " ,Password: " . $password " ,Email : " . $email;
&#34; Prepared语句用于清理你的输入,为此你可以使用:foo,在SQL中没有任何单引号来绑定变量,然后在execute()函数中传递一个数组您在SQL语句中定义的变量。&#34; @Novocaine(https://stackoverflow.com/users/871150/novocaine)。