加上echo $sql;
看看$sql是什么内容;

解决方案 »

  1.   

    $num = mysql_numrows($result)
    mysql_num_rows是不是打错了,
    后面再加上句 echo $num.";kkkkkkkk"看$num是什么内容,
      

  2.   

    mysql_numrows
    改为
    mysql_num_rows
      

  3.   

    $num = mysql_num_rows($result)
    or die ("You're not authorized to be here.");
      

  4.   

    $num = mysql_numrows($result)
    or die ("You're not authorized to be here.");
    改为
    $num = mysql_num_rows($result)
    or die ("You're not authorized to be here.");
      

  5.   

    if ($num == 1) {
    echo "your id is '$id'";
    echo "your username is '$username'";
    echo "your password is '$password'";
    }
    ???只有一条记录?
    if (!$num == 0) {
    echo "your id is '$id'";
    echo "your username is '$username'";
    echo "your password is '$password'";
    }
      

  6.   

    这样:
    login.php
    --------------------
    <? require("connection.php"); ?>
    <?
    $sql = "SELECT * FROM csdbs WHERE username='$username' and password='$password'";
    $result = mysql_query($sql)
    or die ("Unable to get results.");
    $num = mysql_numrows($result)
    or die ("You're not authorized to be here.");
    if ($num == 1) {
    $user_datas=@mysql_fetch_array($result);             //<---这样
    echo "your id is '".$user_datas["id']."'";           //<---这样
    echo "your username is '$username'";
    echo "your password is '$password'";
    }
    ?>
      

  7.   

    哦,错了,修改:login.php
    --------------------
    <? require("connection.php"); ?>
    <?
    $sql = "SELECT * FROM csdbs WHERE username='$username' and password='$password'";
    $result = mysql_query($sql)
    or die ("Unable to get results.");
    $num = mysql_numrows($result)
    or die ("You're not authorized to be here.");
    if ($num == 1) {
    $user_datas=@mysql_fetch_array($result);             //<---这样
    echo "your id is '".$user_datas["id"]."'";           //<---这样
    echo "your username is '$username'";
    echo "your password is '$password'";
    }
    ?>
      

  8.   

    好孩子乖不哭.当然只有一条记录了.难道你那里可以从用户名吗?而且连密码都是一样的.那要从的干什么呢.你一次登录也只上登录一个不是.if (!$num == 0) {
    echo "your id is '$id'";
    echo "your username is '$username'";
    echo "your password is '$password'";
    }
    这个什么意思呀.没有找到你返什么用户和密码值呀.你的如果显示了一条也就是说你的已经好使了.
    sql语句上出错的时候比较多,你可以先显示这个字符看看是否正确.
      

  9.   

    你的程序是多了一个从结果集中取值也就是$aa=mysql_fetch_array($result);这句是把人铁结果集给aa这个数组.然后再从数组中取出值.$aa['id'];这就是你要的id值.
      

  10.   

    mysql_numrows和mysql_num_rows这两个函数都一样的,主要就是在mysql_query语句后没有用$row=mysql_fetch_array($res);然后用$row[id]取值.
      

  11.   

    谢谢!那实际上mysql_fetch_array($result)这个函数是关键啊!我真笨!
      

  12.   

    为什么用$id取值呢?它是无效的.
    如果使用mysql_fetch_rows取值就用字段的数字索引,如果用mysql_fetch_array取值就用名称索引,不用您要注意,用数字索引的速度要快一些,用名称索引的移植性就好一些.