请帮忙!
此INSERT INTO查询有什么问题?!
这是在newUser.php页面上的查询之前
$result2=mysqli_query($con,"SELECT count(*) AS count FROM boards");
while($row2 = mysqli_fetch_array($result2)){
$postNumber=$row2["count"];
}
echo $postNumber;
echo $_POST['bday'];
这是查询
mysqli_query($con,"INSERT INTO users (userID, profPicLoc, age, username, realName, birthday, password, meBoardID, email) VALUES (0, 'aa', 17, '" . $_POST['username2'] . "', '" . $_POST['name'] . "', '" . $_POST['bday'] . "', '" . $_POST['password2'] . "', " . $postNumber+2 . ", '" . $_POST['email'] . "')";
正确连接到数据库,userID是自动增量,数据库中的birthday字段是DATE类型
它在另一页上收到此表格中的信息......
<form action="newUser.php" method="post">
</br>Name: <input type="text" name="name"></input></br>
Username: @<input type="text" name="username2"></input></br>
Password: <input type="password" name="password2"></input></br>
Email: <input type="text" name="email"></input></br>
Birthday: <input type="date" name="bday"></br>
<input type="submit"></input>
</form>
答案 0 :(得分:2)
mysqli_query()
括号关闭错误。最后还需要一个右括号。
如果是AI
user_id
mysqli_query($con,"INSERT INTO users (profPicLoc, age, username, realName, birthday, password, meBoardID, email)
VALUES ('aa', 17, '" . $_POST['username2'] . "', '" . $_POST['name'] . "', '" . $_POST['bday'] . "', '" . $_POST['password2'] . "', " . $postNumber+2 . ", '" . $_POST['email'] . "')");
答案 1 :(得分:1)
使用它:
mysqli_query($con,"INSERT INTO users
(profPicLoc, age, username, realName, birthday, password, meBoardID, email)
VALUES ('aa', 17, '" . $_POST['username2'] . "', '" . $_POST['name'] . "', '" . $_POST['bday'] . "', '" . $_POST['password2'] . "', " . $postNumber+2 . ", '" . $_POST['email'] . "')";
永远不会包含带有自动增量列的主键。