Php 我的项目中的Update语句未更新表中的数据

Php 我的项目中的Update语句未更新表中的数据,php,mysql,sql,database,Php,Mysql,Sql,Database,我正在尝试更新员工的记录。我的查询显示消息“员工记录更新成功”,但表中没有更新。我的代码如下所示 { $eid=intval($_GET['uin']); $uin=$_POST['uin']; $fname=$_POST['firstName']; $lname=$_POST['lastName']; $email=$_POST['email']; $department=$_POST['department']; $recoffr=$_POST['recoffr']; $mobi

我正在尝试更新员工的记录。我的查询显示消息“员工记录更新成功”,但表中没有更新。我的代码如下所示

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

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

您可以尝试以下方法:

 if (isset($_GET['uin'])) {
            $ID = $_GET['uin'];
        } else {
            $ID = "";
        }
    $tblemployees_data = array();
    
        $sql_query = "SELECT firstName, lastName, email, department, recoffr, mobileno
                        FROM tblemployees
                        WHERE uin = ?";
    
    if ($query_category->prepare($sql_query)) {
            // Bind your variables to replace the ?s
            $query_category->bind_param('s', $ID);
            // Execute query
            $query_category->execute();
            // store result
            $query_category->store_result();
            $query_category->bind_result($previous_category_image);
            $query_category->fetch();
            $query_category->close();
        }

在常规日志中查看(并显示)MySQL接收到的最终SQL文本。对吗?通过CLI执行是否会更新行?@Akina我是SQL新手,请解释一下plz@Akina我还是没有那样做working@Akina我的更改如下$query->bindParam(':eid',$uin,PDO::PARAM_STR)@Akina我认为整数不会有任何问题。不管怎样,请建议我在代码中修改什么。@Akina我说的是参数的错误使用name@noone请回显生成的查询并将其添加到问题更新tblemployees set FirstName=:fname,LastName=:lname,email=:email,department=:department,recoffr=:recoffr,电话号码=:mobileno,其中uin=:eid)
 if (isset($_GET['uin'])) {
            $ID = $_GET['uin'];
        } else {
            $ID = "";
        }
    $tblemployees_data = array();
    
        $sql_query = "SELECT firstName, lastName, email, department, recoffr, mobileno
                        FROM tblemployees
                        WHERE uin = ?";
    
    if ($query_category->prepare($sql_query)) {
            // Bind your variables to replace the ?s
            $query_category->bind_param('s', $ID);
            // Execute query
            $query_category->execute();
            // store result
            $query_category->store_result();
            $query_category->bind_result($previous_category_image);
            $query_category->fetch();
            $query_category->close();
        }