0
function DisplayPoints()
{

mysql_select_db('$database');
$qry = "Select points from $this->tablename where username='$username' and password='$pwd' and confirmcode='y'";
    $rows = mysql_fetch_array($qry);
        $points = $rows['points'];
    echo " $points";

}

我的想法是在网站上建立一种积分系统。当用户登录页面然后在主页标题中,您可以看到您有多少积分。

4

1 回答 1

4

mysql_fetch_array 需要结果资源而不是 SQL 查询。请参阅文档: http: //php.net/manual/en/function.mysql-fetch-array.php

首先得到结果:

$result = mysql_query($qry);

然后获取数组

$rows = mysql_fetch_array($result);

正如丹尼斯所指出的,你不应该再使用 mysql_* 了。请改用 PDO 或 mysqli_*。

于 2013-06-18T19:47:18.953 回答