MySQLi num_rows returns 0

前端 未结 3 1471
北荒
北荒 2020-12-22 07:28

Here\'s my code

$stmt = $conn->mysqli->stmt_init();
$stmt = $conn->mysqli->prepare(\'SELECT Username, EmailVerified, Blocked FROM user WHERE Emai         


        
3条回答
  •  滥情空心
    2020-12-22 07:57

    Don't use store_result and get_result together in the same statement.

    Use store_result method with "num_rows", "bind_result" and "fetch".

    For get_result method, use "affected_rows" and "fetch_array". You can still use the "num_rows" property in the income get_result method as shown below.

    $stmt->execute();
    // $stmt->store_result();
    $result = $stmt->get_result();
    if(result->num_rows == 0){
      ...
    }
    

    OR

    $stmt->execute();
    // $stmt->store_result();
    $result = $stmt->get_result();
    if($stmt->affected_rows == 0){
      ...
    }
    

提交回复
热议问题