尽管仅执行一个查询,但命令不同步错误

时间:2019-07-08 07:48:46

标签: php

我正在执行一个查询,然后是为什么出现错误'Commands out of sync; you can't run this command now' in C:\wamp\www\classlearn\delete.php on line 65。这种错误可能会在同时查询期间引起,在我看来,这并非如此。这是我的代码:

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";
    }
}

我检查了查询的正确性,并尝试使用直接query而不是prepare语句。但是,效果是一样的。可能是什么原因?

0 个答案:

没有答案