Unserialize of array returns bool(false)

I am serializing an array to pass through the POST, but it always fails when I unserialize. Here is the info.

Page 1

if (isset($_POST['go'])) {

$locations = array();

	foreach($_POST as $key=>$value) {

		if (strpos($key,"location") !== FALSE) {

		$locations[$key] = $value;

		}

	}

	$locations1 = addslashes(serialize($locations));

...

<input type="hidden" name="locations" value='<?php echo $locations1; ?>'>


Next page I have

$locations = unserialize(stripslashes($_POST['locations']));

And it returns bool(false). If I var_dump() without unserializing the variable looks fine as:

string(62) “a:2:{s:9:\“location0\”;s:1:\“1\”;s:9:\“location1\”;s:1:\“2\”;}”

So what the heck is wrong? now that I look at it, it’s not stripping the slashes. any idea why?

What do you see when you view the source code of the var_dump’ed string? Has it had slasses added to it twice over?

You might need to strip the slashes that magic quotes adds, and then strip the slashes that you initially added there.