简体   繁体   中英

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. You're using eid parameter in your query while binding parameter you are using 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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