我想知道为什么每次运行这个 php 脚本时我的查询都会失败。错误是:致命错误:查询失败!SQL:-错误:在第 19 行的 /home/eland/u5/kbecs/w1268094/public_html/UWSU-Debating-Portal/admin/inventory.php
这是第 19 行的代码:
$question = mysqli_real_escape_string($link,$_POST['question']);
$venue = mysqli_real_escape_string($link,$_POST['venue']);
$date = mysqli_real_escape_string($link,$_POST['questiondate']);
//See if question is identical to another question in the table
$sql = mysqli_query($link,"SELECT qQuestionNo FROM DebateQuestion WHERE question='$question'LIMIT 1");
$questionMatch = mysqli_num_rows($link, $sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error(db_conx), E_USER_ERROR);; //count the output amount
if ($questionMatch>0){
echo 'Sorry you tried to place a duplicate "Question" into the table, <a href="inventory.php">Click here</a>';
exit();
}
//Add the question to the database
$sql = mysqli_query($link,"INSERT INTO DebateQuestion (qQuestion, qDebateVenue, qDate)
VALUES($link,'$question','$venue','$date'") or die (mysqli_error());
$qid = mysqli_insert_id();
header("Location: inventory.php");
exit();
}