$num = mysql_num_rows($result) or die ("You're not authorized to be here.");
$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.");
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'"; }
这样: 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'"; } ?>
哦,错了,修改: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'"; } ?>
好孩子乖不哭.当然只有一条记录了.难道你那里可以从用户名吗?而且连密码都是一样的.那要从的干什么呢.你一次登录也只上登录一个不是.if (!$num == 0) { echo "your id is '$id'"; echo "your username is '$username'"; echo "your password is '$password'"; } 这个什么意思呀.没有找到你返什么用户和密码值呀.你的如果显示了一条也就是说你的已经好使了. sql语句上出错的时候比较多,你可以先显示这个字符看看是否正确.
mysql_num_rows是不是打错了,
后面再加上句 echo $num.";kkkkkkkk"看$num是什么内容,
改为
mysql_num_rows
or die ("You're not authorized to be here.");
or die ("You're not authorized to be here.");
改为
$num = mysql_num_rows($result)
or die ("You're not authorized to be here.");
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'";
}
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'";
}
?>
--------------------
<? 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'";
}
?>
echo "your id is '$id'";
echo "your username is '$username'";
echo "your password is '$password'";
}
这个什么意思呀.没有找到你返什么用户和密码值呀.你的如果显示了一条也就是说你的已经好使了.
sql语句上出错的时候比较多,你可以先显示这个字符看看是否正确.
如果使用mysql_fetch_rows取值就用字段的数字索引,如果用mysql_fetch_array取值就用名称索引,不用您要注意,用数字索引的速度要快一些,用名称索引的移植性就好一些.