It sounds like you are trying to directly save the altered information to the serialized value in the database. You can’t do that.
You have to extract the current meta data for that key so that you have and array or object, update that array or object, and then save the whole thing back to the database.
Something like…
$old_meta = get_post_meta( $pId, 'my_meta', true);
$old_meta['somekey'] = $new_value;
update_post_meta( $pId, 'my_meta', $old_meta );
Note: get_post_meta
will unserialize
for you.
Also be aware that update_post_meta
takes a fourth parameter…
update_post_meta($post_id, $meta_key, $meta_value, $prev_value);
That parameter is optional but if used is intended to…
… differentiate between several fields with the same key. If
omitted, and there are multiple rows for this post and meta key, all
meta values will be updated.http://codex.wordpress.org/Function_Reference/update_post_meta
You can use that to make sure you only overwriting the key/value you intend to overwrite.