I have the following select values:

<select name="vibe_quiz_tags[]" id="vibe_quiz_tags" multiple="" class="chzn-select chosen select2-hidden-accessible" tabindex="-1" aria-hidden="true">
   <option value="">Select Taxonomy</option>
   <option value="4">Test1</option>
   <option value="5">Test2</option>

I post these variables and serialize them with the following code:

$categories = serialize($_POST["vibe_quiz_tags"]);
echo $categories;

I then get the following code when it is output:

I update the post meta with the following:

update_post_meta($quiz_id, 'vibe_quiz_tags', $categories);

When it gets inserted into the database it adds an s:30 at the beginning. Here is what is actually stored in the database:

Why is wordpress adding the s:30 at the beginning?


This happens when an already serialized string get serialize again.


$categories = serialize($_POST["vibe_quiz_tags"]);


$categories = $_POST["vibe_quiz_tags"];


As mentioned by czerspalace in the comments, the Function Reference for update_post_meta states that "this should be raw as opposed to sanitized for database queries".

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.