doupu7651
2013-06-18 19:40
浏览 23
已采纳

mysql函数语法错误[关闭]

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";

}

My idea was to make kind of points system in website. When user logins into page then in main page header you can see how much points you have.

图片转代码服务由CSDN问答提供 功能建议

  function DisplayPoints()
 {
 
mysql_select_db('$ database'); 
 $  qry =“从$ this-> tablename中选择点,其中username ='$ username'和password ='$ pwd'和confirmcode ='y'”; 
 $ rows = mysql_fetch_array($ qry); 
 $ points =  $ rows ['points']; 
 echo“$ points”; 
 
} 
   
 
 

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

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dtuy84033 2013-06-18 19:47
    已采纳

    mysql_fetch_array needs a result resource and not an SQL query. See documentation: http://php.net/manual/en/function.mysql-fetch-array.php

    first get the result:

    $result = mysql_query($qry);
    

    and then fetch the array

    $rows = mysql_fetch_array($result);
    

    As Dennis pointed out, you shouldnt be using mysql_* anymore. Use PDO or mysqli_* instead.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题