Home  >  Article  >  Backend Development  >  PHP提取数据的有关问题

PHP提取数据的有关问题

WBOY
WBOYOriginal
2016-06-13 12:36:01789browse

PHP提取数据的问题
//接收数据
//表单使用post验证
 $conn=mysql_connect('localhost','root','wampp');
  if(!$conn)
  {
    echo"数据库连接失败".mysql_error();
  }
  else
  {
  echo"数据库连接成功";
  }
  
  //设置编码
  //都是使用双引号
 mysql_query("set names 'GBK'") or die(mysql_error());
  
  //选择数据库
 mysql_select_db('employ',$conn) or die("错误的原因是".mysql_error());

 $id=$_POST['id'];
 $pwd=$_POST['pwd'];


//使用数据库验证、、
//数据库语句
 $sql="select * from admin where id=$id";
//数据库执行语句
 $result=mysql_query($sql,$conn)

 //取出关联数组,id号对应密码

if($row = mysql_fetch_array($result))
  
  { //查询到数据库,要取出数据库的密码
   if($row['pwd']=$pwd)
   {
   
   $name=$row['name'];
   header("Location:manage.php?name=$name");
   exit();
   }
  }
  header("Location:login.php?error=1");
   exit();
   
?>以上是代码,这是对用户登录进行处理的页面代码,运行时if($row=mysql_fetch_assoc($result))这个位置,数据库连接的神马的都没有错误,总是报错,求解答

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn