可能重复:
Warning: mysql_fetch_* expects parameter 1 to be resource, boolean given error
我明白了:
“资源ID#8 警告:mysql_fetch_array()期望参数1为资源,字符串为“
下面是代码:
$sql="SELECT password FROM user WHERE userid=$userid";
echo $password=mysql_query($sql);
while($row = mysql_fetch_array($password)) {
$password = $row['password'];
}
有什么想法吗?
答案 0 :(得分:2)
你在循环中覆盖$password
:
while($row = mysql_fetch_array($password)) { <-------- $password as resource
$password = $row['password']; <-------- $password as string
}
这应该有效:
while($row = mysql_fetch_array($password)) {
$password_record = $row['password'];
}