简体   繁体   English

更新查询显示成功但未更新表中的数据

[英]Update query showing successful but it is not updating the data in table

My following query showing "Employee record updated Successfully" but it is not updating in the table what is wrong in my code我的以下查询显示“员工记录更新成功”,但它没有在表中更新我的代码有什么问题

{
$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";

}

You have the problem in the last parameter after where in your query.您在查询中的where之后的最后一个参数中遇到问题。 You're using eid parameter in your query while binding parameter you are using uin .您在查询中使用eid参数,同时使用uin绑定参数。

Update your this line of code.更新您的这行代码。

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

To this:对此:

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

Moreover your not using $eid variable anywhere in your code here.此外,您没有在代码中的任何地方使用$eid变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM