gpt4 book ai didi

php - 从表格发帖不起作用

转载 作者:行者123 更新时间:2023-12-01 00:39:53 24 4
gpt4 key购买 nike

当我点击提交按钮时,估算的数据应该进入下面的查询,但它没有。

好像按钮的值被代替了。

有人能弄清楚为什么它不起作用。它与我的登录页面使用的代码相同,并且有效。

它转到 if 语句的 else 部分

错误:

Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM test_set WHERE Room_Code='room'' at line 1

查询:

if (isset($_POST['room']))
{
require "connect.php";

if (count($_POST) > 0)
{
$result = mysqli_query($conn, "SELECT id, FROM test_set WHERE Room_Code='" . $_POST["room"] . "'");
if (!$result) {
printf("Error: %s\n", mysqli_error($conn));
exit();
}
$row = mysqli_fetch_array($result);
if (is_array($row))
{
$_SESSION["Room_ID"] = $row['id'];
header("Location: ../views/student/question.php?id='" . $_SESSION["Room_ID"] . "'");
}
else
{
echo "No";
}
}
}

表格:

 <form method="POST" name="room" action="../../config/functions.php">
<label for="room" class="sr-only">Room Code</label>
<input type="text" id="room" name="room" class="form-control" placeholder="Please Enter Room Code">
<br>
<input type="submit" class="waves-effect waves-light btn blue darken-3" name="room" value="room">
</form>

编辑:

仍然不工作也以这种方式改变:

$result = mysqli_query($conn, "SELECT id FROM test_set WHERE Room_Code='" . $_POST["room"] . "'");

最佳答案

从您的查询中删除 ,:

SELECT id,

$result = mysqli_query($conn, "SELECT id FROM test_set 
WHERE Room_Code='" . $_POST["room"] . "'");

关于php - 从表格发帖不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35535993/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com