unserialize getting wrong data type?

I’ve got a couple of times in one form that I serialize an array to store as one variable in the mysql database. Two of the four are not working right. I’m getting this error:

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/.nelya/amosglenn/amosglenn.com/campaign/contactform.php on line 71

What I’m doing is to check the array to see if the user has signed up for a specific day (there is a group of checkboxes that go into the array.

It looks like the array is being stored correctly (at least it looks like a serialized array, that is, a bunch of letters numbers and punctuation). But the form seems to think that I’m not getting an array back when I unserialize the value from the database.

Here is the code that unserializes the variable retrieved from the database:

	<table cellpadding='6'>
		<tr class='grouplabel'><td colspan='2'>Discussion Group Information</td></tr>
		<tr><td colspan='2'>
			<table cellpadding='6'>
					$cdd = unserialize($cdiscussionday);

				<tr><td>The best days for me to meet with a group is:</td></td>
				<tr><td><input type="checkbox" name="discussionday[]" value="sunday" 
<?php if(in_array("sunday",$cdd)) {print('CHECKED');} ?> 

<!-- the rest of the days are identical, snipped here for readability -->

And here is the code that serializes the information for starage:

[code] isset($_POST[‘discussionday’]) ? $cdiscussionday = serialize($_POST[‘discussionday’]) : $cdiscussionday="";

isset($_POST['discussiontime']) ? $cdiscussiontime = serialize($_POST['discussiontime']) : $cdiscussiontime="";

I’ve read everything on serialization I can find, but this is driving me crazy.
Thanks for any help!

try echoing ut $cdiscussionday befor and after (un)unserialization.

i don’t thing the error is within the code u posted. maybe the varibles u try to unserialize are empty.

and use error_reporting(E_ALL) at the beginning of ur php-code

Sponsor our Newsletter | Privacy Policy | Terms of Service