John,
Using your example with addslashes(), and look at the result:
<?php
$var[] = "one";
$var[] = "two";
$var[] = 1;
$var[] = 2;
$var[] = "That's good";
$ser = addslashes( serialize( $var ) );
echo $ser;
?>
That will produce the output:
a:5:{i:0;s:3:\"one\";i:1;s:3:\"two\";i:2;i:1;i:3;i:2;i:4;s:11:\"That\'s good\";}
If you put this in a hidden form:
- <input type=hidden name=ser value='<?php echo $ser; ?>'>
- <input type=hidden name=ser value="<?php echo $ser; ?>">
- <input type=hidden name=ser value=<?php echo $ser; ?>>
You will obtain the result:
a:5:{i:0;s:3:\"one\";i:1;s:3:\"two\";i:2;i:1;i:3;i:2;i:4;s:11:\"That\
a:5:{i:0;s:3:\
a:5:{i:0;s:3:\"one\";i:1;s:3:\"two\";i:2;i:1;i:3;i:2;i:4;s:11:\"That\'s
So, the use of addslashes() don't work! I prefer to use the "1." method, but replace the plicks (') for other non-printable character, always setting the magic_quotes to Off.
Marco Antonio