You should look like this:
try {
$b = $_POST['key_id'];
$stmt = new mysqli("example.com", "user", "password", "database");
$stmt->prepare("Update serialized_data set value=? WHERE id = ?");
$stmt->bind_param("si",$str1, $b);
$stmt->execute();
} catch(Exception $e){
echo $e->getMessage();
}
However, I would prefer to use a string jsoninstead of a serialized string.
Something like that
$data = array('key' => 'val');
$a = json_encode($data);
then when you select a row from the database you will use json_decode($selectedString); // this will convert your json string into an object
source
share