这个php插入查询在MYSQL xampp中不起作用。我找不到任何错误
QUERY:
$query = "INSERT INTO member (id, username,fname,lname,email, password, salt )
VALUES ( '$username', '$password', '$email', '$salt' )";
答案 0 :(得分:1)
你缺少$ fname,查询中的$ lname如果自动增加,也会使用NULL作为id
$query = "INSERT INTO member (id, username,fname,lname,email, password, salt )
VALUES (NULL, '$username', '$fname', '$lname', '$password', '$email', '$salt' )";
答案 1 :(得分:0)
您传递的列名称数量错误。您的正确查询应如下所示:
$query = "INSERT INTO member (username,password,email,salt )
VALUES ( '$username', '$password', '$email', '$salt' )";
答案 2 :(得分:0)
您没有向查询中指定的所有列插入值。
在您的查询中
$query = "INSERT INTO member (id, username,fname,lname,email, password, salt )
VALUES ( '$username', '$password', '$email', '$salt' )";
您指定了7列且只有4个值。因此,可以添加更多值或删除查询中指定的不必要的列,如
$query = "INSERT INTO member (username, password,email, salt )
VALUES ( '$username', '$password', '$email', '$salt' )";
OR
$query = "INSERT INTO member (id, username,fname,lname,email, password, salt )
VALUES ('$id', '$username','$fname','$lname','$email', '$password', '$salt' )";