I am executing a single query, then also why there is error 'Commands out of sync; you can't run this command now' in C:\wamp\www\classlearn\delete.php on line 65
. Such error may cause during simultaneous queries, which is not in my case. Here's my code:
if(isset($_POST['delete'])){
error_reporting(E_ALL);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$rn = $_POST['del_rn'];
$check = $conn->prepare("SELECT name FROM `students` WHERE rollno=?");
$check->bind_param("s",$rn);
$check->execute();
$rows = $check->fetch();
if($rows>0){
$stmt_student = $conn->prepare("DELETE FROM `students` WHERE rollno=?"); //line 65
$stmt_student->bind_param("i",$rn);
if($stmt_student->execute()){
echo "Record deleted successfully";
} else{
echo "Record not deleted";
}
} else{
echo "Record does not exists";
}
}
I have checked query is correct and also tried with direct query
instead of prepare
statement. But, the effect is same. What could be the reason?