[英]Having an issue deleting rows from server
So in short i am having issues getting my code to remove rows from my database table "tblsurvey" when i run the code there is no errors displaying and it appears to execute the statement correctly however when checking the table i find the row has not been deleted. 简而言之,当我运行代码时,我遇到了使代码从数据库表“ tblsurvey”中删除行的问题,没有显示错误,并且似乎可以正确执行该语句,但是当检查表时,我发现行没有被执行已删除。
<?php //set a question from the database V1.0
require '../configure.php'; //required to connect to the DB
//initialising variables
$qID = ''; //question ID
$dropDown = ''; //drop down box
$startSelect = '<select name=drop1>'; //initial value of select
$endSelect = '</select>'; //end of select
$fullHTML = ''; //display the dropdown menus options
$getDropdownID = ''; //on button submit grabs the UID for the questionairre
$hiddenTag = '';
$DB = "questonaire"; //must match Database
$db_isFound = new mysqli(DB_SERVER, DB_USER, DB_PASS, $DB); //connecting to the database see ../configure.php for details
//checking if button as been pressed -- needs to redirect to the appropriate questionaire on pressed
if (isset($_GET['submit'])){
//initialising the selected questionaire ID
$getDropdownID = $_GET['drop1'];
//display the selected questionaire
if ($db_isFound){
$SQL = "DELETE FROM tblsurvey WHERE ID = ?";
$SQL_stmt = $db_isFound->prepare($SQL);
if($SQL_stmt){
$SQL_stmt->bind_param("s", $qID);
$SQL_stmt->execute();
print("question has been successfully removed from the database.");
}else{
print("There was a problem running your query: row not deleted");
}
}else{
print("error connecting to DB: Question not deleted");
}
}
It outputs correctly and displays 正确输出并显示
print("question has been successfully removed from the database.");
however the row is not removed from the table. 但是该行不会从表中删除。
any help would be greatly appreciated. 任何帮助将不胜感激。
in this line 在这条线
$SQL_stmt->bind_param("s", $qID);
replace $qID
for $getDropdownID
because I don't see where $qID
get value. 将
$qID
替换为$getDropdownID
因为我看不到$qID
价值所在。
谢谢您看一下,我有点放屁了,在准备好的声明中称错误的var为解决方法
$SQL_stmt->bind_param("i", $getDropdownID);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.