Hi the error you are getting for $serializedpaisol
variable because it is not define in function scope.
the variable you define in specific scope can not access out form its scope;
eg.
{
//example scope
$var=10;
}
echo $var; // you will get undefined error.
how you can fixed it?
Solution
// first define variable in function scope
$serializedpaisol ="";
if(isset($paisol)){
$serializedpaisol = maybe_serialize($paisol);
}
echo $serializedpaisol; // now you will not get any error.
hope you understand the point.
Thanks