$sql="select stu_id,stu_password from studentPwd2";
$res=sqlsrv_query($conn,$sql);
while($r=sqlsrv_fetch_array($res))
{
$b=md5('$r[1]');
echo $r[1]."对应MD5".$b."<br />";
$sql2="update studentPwd2 set stu_password='".$b."' where stu_id='".$r[0]."'";
echo $sql2."<br />";
sqlsrv_query($conn,$sql2);
}
我想把之前的密码都变成MD5加密的,然后就这样子,为什么密码都变成一样的了
123456对应MD5ab71f115b2cd70037a03031f9827b924
update studentPwd2 set stu_password='ab71f115b2cd70037a03031f9827b924' where stu_id='ID1'
111111对应MD5ab71f115b2cd70037a03031f9827b924
update studentPwd2 set stu_password='ab71f115b2cd70037a03031f9827b924' where stu_id='ID2'
------解决方案--------------------
$b=md5('$r[1]');
即使加引号也应该是双引号而不是单引号
------解决方案--------------------
嗯, 引号的问题,把引号去掉