使用pdo更新多个Mysql行

时间:2017-03-03 07:12:13

标签: php mysql pdo

大家好,我开始之前我想指出我已经通过以下链接和更多

How to update multiple columns in mysql using php PHP: Update multiple MySQL fields in single query

我正在尝试更新数据库中的几行,这是我的代码:

$stmt = $user->runQuery("SELECT * FROM tbl_client_info WHERE UCODE=:uid");
$stmt->execute(array(":uid"=>$_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);

    if($stmt->rowCount() == 1)
    {
        if(isset($_POST['btn-update-data']))
        {
            $pass = $_POST['pass'];
            $cpass = $_POST['confirm-pass'];
            $name = $_POST['firstname'];
            $lastname = $_POST['lastname'];
            $email = $_POST['billingemail'];
            $cell = $_POST['Cell'];

            if($cpass!==$pass)
            {
                $msg = "<div class='alert alert-block'>
                        <button class='close' data-dismiss='alert'>&times;</button>
                        <strong>Sorry!</strong>  Input Does Not Match. Make sure the details match. 
                        </div>";
            }
            else
            {


                $stmt = $user->runQuery("UPDATE `tbl_client_info` SET 
                    firstname =:name, 
                    lastname =:lastname, 
                    email =:billingemail, 
                    Cell =:cell, 
                    password=:upass, 
                    where UCODE=:uid");

                    $stmt->bindparam(":firstname",$name);
                    $stmt->bindparam(":lastname",$lastname);
                    $stmt->bindparam(":billingemail",$email);
                    $stmt->bindparam(":Cell",$cell);
                    $stmt->bindparam(":upass",$pass);
                    $stmt->execute();

我没有得到任何错误,但我很确定问题出在绑定参数中。我最终只获得了一份文件移动 - 这个文件可以在这里找到。

是的我要添加password_hash;)

请提供任何帮助

0 个答案:

没有答案