查询在数据库中受到影响,但它仍然在 PHP 中显示错误消息

query is getting affected in database but still it is showing error message in PHP

这部分代码是我用来通过令牌验证更新密码的,我从 url 以加密格式获取用户邮件,这就是我在查询中使用 md5 的原因。 查询正在执行并正确影响 table,但它一直显示 else 错误消息。

    $password= md5($_POST['password']);
    $sqlupdateaccount="UPDATE `mydatabasename`.`usertbl` 
                        SET `password`='$password' 
                        WHERE MD5(`useremail`)='$useremail' 
                        AND `token`='$token'";
    $result=mysqli_query($con,$sqlupdateaccount);
    if(mysqli_num_rows($result)>0)  // also used if(mysqli_affected_rows($con)) but still same problem
    {
        header("Location:userlogin.php?s=1");
    } else {
        echo "<h3 class='alert alert-danger'>Something Went Wrong</h3>".mysqli_error($con);
    }

mysqli_num_rows 应该在您有 select 查询时使用。

mysqli_affected_rows 是您要搜索的内容。

if(mysqli_num_rows($result)>0) {...更改为if(mysqli_affected_rows($con)>0) {...