我收到错误" mysql_fetch_assoc()期望参数1是资源"我相信我错过了一些东西,但我不知道它可能是什么。如果我删除" mysql_fetch_assoc"我得到了类似的错误。我是PHP的新手。
if ($username) {
if ($_POST['submit']) {
$oldpassword = $_POST['oldpassword'];
$newpassword = $_POST['newpassword'];
$repeatnewpassword = $_POST['repeatnewpassword'];
$connect = mysqli_connect("", "", "", "");
mysqli_select_db($connect, "phplogin");
$queryget = ("SELECT password FROM users WHERE username = '$username'") or die("Error: Unregistered user.");
$row = mysql_fetch_assoc($queryget);
$oldpassworddb = $row['password'];
if ($oldpassword==$oldpassworddb)
{
if ($newpassword==$repeatnewpassword) {
echo "yay!";
}
else
die("Error: New passwords don't match.");
}
else
die("Error: Wrong initial password.");
}
}
else
die("Error: Must be logged in.");
这是什么意思,如何解决?
答案 0 :(得分:1)
您实际上并没有进行查询,因此您需要
$queryget = mysql_query("SELECT password FROM users WHERE username = '$username'")
mysql_query()
会返回resource
。