这是我的代码:各位大侠帮我看下哪里出错了。
$id=$_POST["id"];
$pwd=$_POST["pwd"];
$indentitys=$_POST["identitys"];
$sql = "SELECT id FROM admins WHERE id='$id'";
//echo $sql;
$res=mysql_query($sql);
if ($res['id']==$id) {
echo '用户名已存在,请重新输入';
eixt;
}else {
$sql = "insert into admins(id,pwd,Identitys) value('$id','$pwd','$indentitys')";
echo("<meta http-equiv=refresh content=0;url=Clients.php>");
echo"添加成功";
}
第1个回答 2010-06-03
$res=mysql_query($sql);
返回的不是数组,需要用mysql_fetch_array()获取记录。所以$res['id'] 不能这样用的。和 asp 的 recordset不一样的
还有 $sql = "insert into admins(id,pwd,Identitys) value('$id','$pwd','$indentitys')";
echo("<meta http-equiv=refresh content=0;url=Clients.php>");
需要 mysql_query($sql);来执行 $sql
返回的不是数组,需要用mysql_fetch_array()获取记录。所以$res['id'] 不能这样用的。和 asp 的 recordset不一样的
还有 $sql = "insert into admins(id,pwd,Identitys) value('$id','$pwd','$indentitys')";
echo("<meta http-equiv=refresh content=0;url=Clients.php>");
需要 mysql_query($sql);来执行 $sql
第2个回答 推荐于2016-08-23
$res=mysql_query($sql);
if ($res['id']==$id) {
改为
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
if ($row['id']==$id) {
祝你好运本回答被提问者采纳
if ($res['id']==$id) {
改为
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
if ($row['id']==$id) {
祝你好运本回答被提问者采纳