How to UPDATE in database using mysqli prepared statement?

后端 未结 1 1620
隐瞒了意图╮
隐瞒了意图╮ 2020-12-22 07:51

I\'m using mysqli before to my query and now I convert it to mysqli prepared statements. I\'m trying to update a particular data with upload image and I don\'t know why I ge

相关标签:
1条回答
  • 2020-12-22 08:39

    For procedural way

    $query = "UPDATE `crew_info` SET `updated_photo` = ? WHERE `id` = ?";
    $stmt = mysqli_prepare($conn, $query);
    // you should use i instead of s for id
    mysqli_stmt_bind_param($stmt, 'si', $imageData, $_GET['id']);
    mysqli_stmt_execute($stmt);
    

    Try this out in object-oriented style

    $query = "UPDATE `crew_info` SET `updated_photo` = ? WHERE `id` = ?";
    $stmt = $conn->prepare($query);
    $stmt->bind_param("si", $imageData, $_GET['id']);
    $stmt->execute();
    
    0 讨论(0)
提交回复
热议问题