PHP 中 资源释放问题 20
<?php//接收ID$id=$_POST['id'];//接收密码$password=$_POST['password'];$conn=mysql_connect("l...
<?php
//接收ID
$id =$_POST['id'];
// 接收密码
$password=$_POST['password'];
$conn=mysql_connect("localhost","root","root");
if(!$conn){
die ("连接失败".mysql_errno());
}
mysql_query("set names utf8",$conn) or die(mysql_errno);
mysql_select_db("empmanage",$conn) or die(mysql_errno);
$sql="select password from admin where id= $id";
$res=mysql_query($sql,$conn);
if($row=mysql_fetch_assoc($res)){
if($row['password']==md5($password)){
header("location:empManage.php");
exit();
}
header("location:login.php?errno=1");
exit();
}
// mysql_free_result($res);
mysql_close($conn);
// 验证用户
// if($id=="100" && $password == "123"){
// echo "合法用户";
// header("Location: empManage.php");
// exit();
// }else{
// echo "非法用户";
// header("Location: login.php?error=1");
// exit();
// }
?>
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in D:\phpStudy\WWW\empManage\empManage\loginProcess.php on line 22 展开
//接收ID
$id =$_POST['id'];
// 接收密码
$password=$_POST['password'];
$conn=mysql_connect("localhost","root","root");
if(!$conn){
die ("连接失败".mysql_errno());
}
mysql_query("set names utf8",$conn) or die(mysql_errno);
mysql_select_db("empmanage",$conn) or die(mysql_errno);
$sql="select password from admin where id= $id";
$res=mysql_query($sql,$conn);
if($row=mysql_fetch_assoc($res)){
if($row['password']==md5($password)){
header("location:empManage.php");
exit();
}
header("location:login.php?errno=1");
exit();
}
// mysql_free_result($res);
mysql_close($conn);
// 验证用户
// if($id=="100" && $password == "123"){
// echo "合法用户";
// header("Location: empManage.php");
// exit();
// }else{
// echo "非法用户";
// header("Location: login.php?error=1");
// exit();
// }
?>
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in D:\phpStudy\WWW\empManage\empManage\loginProcess.php on line 22 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询