Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8050641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:07:48+00:00 2026-06-05T07:07:48+00:00

I have problem with Unserialize which return nothing after getting it from $_POST. I

  • 0

I have problem with Unserialize which return nothing after getting it from $_POST. I post a simple array from a form and I could see double quotes been added to the serialized string. I tried stripslashes before serialzing and before unserializing, but the result is the same with no output. I have turned of magic_quotes_gpc in php.ini and again no luck. When I hardcode the values in unserialize by adding “\” manually gave me the desired string, So I tried with addslashes and again left with nothing. Please help me resolve this.

<?php


$tmp = $_POST["strVid"];

$myNewArray = unserialize($trp);
print_r($myNewArray);

$myArray = array('key1'=>'value1', 'key2'=>'value2');
$serialized = serialize($myArray);
?>

<form  onsubmit="return validate(this)" action="test_serialize.php" method="post">
<input type="hidden" name="strVid1" value="this is mega shit"/>
<input type="hidden" name="strVid" value="<?php echo $serialized; ?>">
<input type="Submit" name="next" value="Next"/>

</form>

Updated…

After Serialize: a:2:{s:4:”key1″;s:6:”value1″;s:4:”key2″;s:6:”value2″;}

After stripslashes of Serialize: a:2:{s:4:”key1″;s:6:”value1″;s:4:”key2″;s:6:”value2″;}

when I add \ manually

$myNewArray = unserialize(“a:2:{s:4:\”key1\”;s:6:\”value1\”;s:4:\”key2\”;s:6:\”value2\”;} “);

I get the output as Array ( [key1] => value1 [key2] => value2 )

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:07:49+00:00Added an answer on June 5, 2026 at 7:07 am

    In your code:

    <input type="hidden" name="strVid" value="<?php echo $serialized; ?>">
    

    That’s most certainly wrong, because the variable will contain double quotes; you must escape those:

    <input type="hidden" name="strVid" value="<?php echo htmlspecialchars($serialized, ENT_QUOTES, 'UTF-8'); ?>">
    

    Btw, this is assuming you’re doing this to unserialize it:

    $myNewArray = unserialize($_POST["strVid"]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have problem while getting data from Memcached on .NET MVC solution. I have this
i have problem to pass data from view to controller , i have view
I have problem with getting value of parameter when I have variable with some
I have problem with Visual Studio Designer. When I display design of a form,
I have a cookie which stores info in an array. This is for a
I have a problem with a WCF service, which tries to serialize too much
I have problem when creating a file in encoding 'utf-8' and reading it from
I have problem in Listview onListItemClick() method. I am not getting the position of
My PHP code serializes, but doesn't unserialize, what could be the problem? $serializedColumns =
I have problem with repopulating form_upload after validation. Other input fields or selectboxes are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.