警告:mysql_fetch_array

时间:2014-09-27 07:49:03

标签: mysql arrays warnings fetch

我得到以下错误:

  

警告:mysql_fetch_array()要求参数1为资源,布尔值为......

这是我的问题:

$result = mysql_query("SELECT * FROM users WHERE username = $user' AND password = '$pass'");
        while($row = mysql_fetch_array($result))
            {
                $expire = time()+60*60*24*30;
                setcookie("id", $row['id'], $expire);
                echo "Logged in. as <b>.".$row['username']."</b>";
            }

1 个答案:

答案 0 :(得分:0)

好像你错过了一个&#39;在这个$ user的左侧(我在这里添加了它):

$result = mysql_query("SELECT * FROM users WHERE username = '$user' AND password = '$pass'");