2017-11-26 2 views
-1

메신저의 PHP 오류 암호 변경 :는 암호 변경 있지만 오류 만들려고 노력

Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in /storage/ssd3/222/2815222/public_html/changepassword.php on line 12

<?php 
    $con = mysqli_connect("localhost", "id2815222_bigbrother", "orwell", "id2815222_orwell"); 

    $studentno = $_POST["studentno"]; 
    $password = $_POST["password"]; 

    $statement = mysqli_prepare($con, "UPDATE tbl_users SET password = ? WHERE studentno = ?"); 
    mysqli_stmt_bind_param($statement, "ss", $username, $password); 
    mysqli_stmt_execute($statement); 

    mysqli_stmt_store_result($statement); 
    mysqli_stmt_bind_result($statement, $id, $studentno, $firstname, $middlename, $lastname, $birthday, $section ,$course, $college, $password, $phonenumber, $email); 

    $response = array(); 
    $response["success"] = false; 

    while(mysqli_stmt_fetch($statement)){ 
     $response["success"] = true; 
    } 

    echo json_encode($response); 
?> 

내가이 문제를 해결할 수있는 방법에 대한 어떤 생각을?

답변

0

업데이트 쿼리 true 또는 false 만 반환하면 업데이트 된 데이터가 반환되지 않습니다. 코드를 아래와 같이 변경하십시오.

<?php 
    $con = mysqli_connect("localhost", "id2815222_bigbrother", "orwell", "id2815222_orwell"); 

    $studentno = $_POST["studentno"]; 
    $password = $_POST["password"]; 

    $statement = mysqli_prepare($con, "UPDATE tbl_users SET password = ? WHERE studentno = ?"); 
    mysqli_stmt_bind_param($statement, "ss", $username, $password); 
    $res = mysqli_stmt_execute($statement); // store result in $res 



    $response = array(); 
    $response["success"] = false; 

    if($res){ //check whether it is true or false 
     $response["success"] = true; 
    } 

    echo json_encode($response); 
?> 
+0

감사합니다. 이제 완벽하게 작동합니다. –

관련 문제