Mysql错误 - 提供的参数不是有效的MySQL结果资源

时间:2013-04-19 08:53:34

标签: mysql

我需要帮助解决此错误:

  

警告:mysql_fetch_assoc():提供的参数不是有效的MySQL   结果资源位于第15行的 * ** * * /log.php。

这是第15行: -

$query = "SELECT COUNT(id) AS amt FROM users WHERE name='$username' password='$password'";
$q = mysql_query($query,$c);
$user = mysql_fetch_assoc($q); // line 15
$amt_found = (int)$user['amt'];

4 个答案:

答案 0 :(得分:0)

你错过了

$query = "SELECT COUNT(id) AS amt FROM users WHERE name='$username' AND password='$password'"; $q = mysql_query($query,$c); $user = mysql_fetch_assoc($q); // line 15 $amt_found = (int)$user['amt'];

答案 1 :(得分:0)

您忘记了and

$query = "SELECT COUNT(id) AS amt FROM users 
WHERE name='$username' AND password='$password'";
                        ^--------------------------here

答案 2 :(得分:0)

你错过了AND

更改name='$username' password='$password'
name='$username' AND password='$password'

$query = "SELECT COUNT(id) AS amt FROM users 
WHERE name='$username' AND password='$password'"; 

答案 3 :(得分:0)

使用

$query = "SELECT COUNT(id) AS amt FROM users WHERE name='$username' AND password='$password'";
$q = mysql_query($query,$c);
$user = mysql_fetch_assoc($q); // line 15
$amt_found = (int)$user['amt'];