Update Data Users in PDO Not Work

后端 未结 1 1983
鱼传尺愫
鱼传尺愫 2021-01-21 10:48

Previously I was using Old MySQL to update, but now I try to change the total to PDO on the recommendation of friends.

However I am constrained when setting up the form

相关标签:
1条回答
  • 2021-01-21 11:16

    What is wrong?

    Frankly - nearly everything. From the class structure to the idea of fetching result of the update query.

    It seems you are using some highly unreliable tutorial to learn PDO. Let me offer one I wrote, (The only proper) PDO tutorial, from which you will easy learn the proper way.

    Here is your update code fixed:

    if(isset($_POST['update']))
    {
        $utentang = strip_tags($_POST['txt_tentang']);
        $stmt = $auth_user->runQuery("UPDATE users SET tentang=:ttg where id=:id");
        $stmt->execute(array(':ttg'=>$utentang, ':id'=>$id));
    }
    

    Note that you should neither bind, fetch or catch here.

    0 讨论(0)
提交回复
热议问题