无法将 md5 哈希输出为数据库中的相同哈希


Can't output md5 hash as the same one in the database

我有一个小问题,希望你能解决。

每当我尝试从数据库中检索哈希时,我都会收到此错误:"where 子句"中的未知列"26657d5ff9020d2abefe558796b99584"

这是我的PHP代码:

<?php
if(isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['hash']) && !empty($_GET['hash'])){
//Verifier les données
    $email = mysql_real_escape_string($_GET['email']);
    $hash = mysql_real_escape_string($_GET['hash']);
    $verification = mysql_query("SELECT email, hash, status FROM utilisateurs WHERE Email = '".$email."' AND
    $hash = '".$hash."' AND status = '0'") or die(mysql_error());
    $match = mysql_num_rows($verification);
    echo $match; // Just for testing how many matches we'll get. We expect "1" or "0"
}else{ 
    //Invalid approach
    echo "Invalid approach, please use the link that has been send to your email.";
}

?>

所以当我测试 url 时:http://mywebsite.com/verify.php?email=name@gmail.com&hash=26657d5ff9020d2abefe558796b99584 我确定哈希存在,因为我使用相同的电子邮件从数据库中复制了它

我收到错误:"where 子句"中的未知列"26657d5ff9020d2abefe558796b99584"

哈希是这样做的:$hash = md5(rand(0,1000));

任何帮助将不胜感激!

您的 SQL 查询包含以下子句:

… AND $hash = '".$hash."' AND …
      ^^^^^

您要检查hash列的值,而不是$hash