Convert from mysqli_query to mysqli prepared statement using mysql PASSWORD function

穿精又带淫゛_ 提交于 2019-12-13 04:16:59

问题


I have converted my website from mysql to mysqli prepared statements except for one query. The query I can't figure out is:

$sql = "SELECT customerID FROM customer WHERE customerEmail = '$loginEmailAddress' AND customerPassword = PASSWORD('$loginPassword');";
$result = mysqli_query($mysqli, $sql);

This works fine. When I try to make an mysqli prepared statement, the problem is the mysql PASSWORD function. Is it even possible to convert this?

I tried things like:

$loginPassword = PASSWORD($loginPassword);

    $stmt = $mysqli -> prepare("SELECT customerID from customer WHERE customerEmail = ? AND customerPassword =  ? ");
        $stmt -> bind_param("ss", $loginEmailAddress,$loginPassword);
        $stmt -> execute();
        $stmt->store_result();
        $stmt -> bind_result($customerID);
        $stmt -> close();

and of course no success. I also tried things like:

$loginPassword  = '" . PASSWORD('$loginPassword') . "';

I am working toward using phpass, but in the meantime I need to keep using PASSWORD for my existing customers until they login and I can move them to the new hash.

来源:https://stackoverflow.com/questions/11781467/convert-from-mysqli-query-to-mysqli-prepared-statement-using-mysql-password-func

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!