我项目中的更新语句不更新表中的数据 [英] Update statement in my project not updating data in table

查看:51
本文介绍了我项目中的更新语句不更新表中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更新Employee的记录。MY查询显示消息雇员记录已成功更新。但是它没有在表中更新。我的代码是这样的

I am trying to update the record of Employee.MY query shows the message "Employee record updated Successfully" but it is not updating in table My code goes like this

{
$eid=intval($_GET['uin']);
$uin=$_POST['uin'];
$fname=$_POST['firstName'];
$lname=$_POST['lastName'];   
$email=$_POST['email']; 
$department=$_POST['department']; 
$recoffr=$_POST['recoffr']; 
$mobileno=$_POST['mobileno'];
$sql="
update tblemployees 
   set FirstName = :fname
     , LastName = :lname
     , email = :email
     , department = :department
     , recoffr = :recoffr
     , Phonenumber = :mobileno 
 where uin = :eid
";
$query = $dbh->prepare($sql);
$query->bindParam(':uin',$uin,PDO::PARAM_STR);
$query->bindParam(':fname',$fname,PDO::PARAM_STR);
$query->bindParam(':lname',$lname,PDO::PARAM_STR);
$query->bindParam(':email',$email,PDO::PARAM_STR);
$query->bindParam(':department',$department,PDO::PARAM_STR);
$query->bindParam(':recoffr',$recoffr,PDO::PARAM_STR);
$query->bindParam(':mobileno',$mobileno,PDO::PARAM_STR);
$query->execute();
$msg="Employee record updated Successfully";

}

我的表结构为表结构

推荐答案

您已分配Uin错误的ID

You have assigned Uin to wrong Id

$query->bindParam(':eid',$uin,PDO::PARAM_STR);

不是

$query->bindParam(':uin',$uin,PDO::PARAM_STR);

这篇关于我项目中的更新语句不更新表中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆