我试图将值添加到phpmyadmin中的表中,但出现错误:“字段列表”中的未知列“ ...”。
$SELECT = "SELECT * FROM battle WHERE time2 < (NOW() - INTERVAL 1400 MINUTE)";
$fire5 = mysqli_query($con,$SELECT)or die(mysqli_error($con));
if (mysqli_num_rows($fire5)>0) {
while($users = mysqli_fetch_assoc($fire5)){
$nowvote = $users['vote'];
$nowvote2 = $users['vote2'];
$userid1 = $users['id1'];
$userid2 = $users['id2'];
$username1 = $users['username'];
$username2 = $users['username2'];
$time2 = $users['time2'];
$avatarpath1 = $users['avatar_path1'];
$avatarpath2 = $users['avatar_path2'];
$query ="SELECT * from users where id=$userid1";
$fire = mysqli_query($con,$query)or die(mysqli_error($con));
if (mysqli_num_rows($fire)>0) {
$users= mysqli_fetch_assoc($fire);
$win = $users['win'];
$userid1 = $users['id'];
}
$query2 ="SELECT * from users where id=$userid2 ";
$fire2 = mysqli_query($con,$query2)or die(mysqli_error($con));
if (mysqli_num_rows($fire2)>0) {
$users= mysqli_fetch_assoc($fire2);
$win1 = $users['win'];
$userid2 = $users['id'];
}
if ($nowvote>$nowvote2) {
mysqli_query($con,"UPDATE users SET win=$win1+1 where id = '$userid2'");
mysqli_query($con, "INSERT INTO winner(avatar_path, username,user_id) VALUES ('$avatarpath1','$username2','$userid2')")or die(mysqli_error($con));
}elseif($nowvote2>$nowvote){
mysqli_query($con,"UPDATE users SET win=$win+1 where id = '$userid1'");
mysqli_query($con, "INSERT INTO winner(avatar_path, username,userid) VALUES ('$avatarpath2','$username1','$userid1')")or die(mysqli_error($con));
}
}
因此,当我执行查询时,我得到:'字段列表'中的未知列'userid'。这以前从未发生过,我也不知道发生了什么。
答案 0 :(得分:0)
不是你的最后一个
mysqli_query($con, "INSERT INTO winner(avatar_path, username,userid) VALUES ('$avatarpath2','$username1','$userid1')")or die(mysqli_error($con));
是
mysqli_query($con, "INSERT INTO winner(avatar_path, username,user_id) VALUES ('$avatarpath2','$username1','$userid1')")or die(mysqli_error($con));
userid ==> user_id?