[thelist] Strange checkbox issue (PHP / Forms)

Sarah Adams sarahwbs at gmail.com
Wed Mar 4 09:19:28 CST 2009

> I have a very strange PHP problem processing checkboxes.
> I have a form "Add Story". Within this form 'subsections' are chosen by 
> checkboxes:
> <input type="checkbox" name="subsection[]" value="1" /> One
> <input type="checkbox" name="subsection[]" value="2" /> Two
> <input type="checkbox" name="subsection[]" value="3" /> Three
> <input type="checkbox" name="subsection[]" value="4" /> Four
> (Please assume that these are enclosed in block level elements, have 
> labels etc, the above is for clarity.
> To process these the following bit of code is used:
> ***********
> if(isset($_POST['subsection'])) {
>    $subsection = implode("|",$_POST['subsection']);
> }
> ***********
> I get the message "Invalid arguments". This appears to be due to 
> $subSection being empty (but PHP still thinking it is an array!).

My suggestion would be to simplify the problem as much as you can. Make
a copy of the scripts involved, then start deleting stuff that
*shouldn't* impact this part of the script (e.g. other form fields and
their related processing code). Keep testing after you remove each bit,
see if anything changes.

Also, just in case - have you double-checked to make sure there are no
other script included somewhere along the way? Since you said the layout
has changed, maybe there is something conflicting in an included file
that wasn't there before? (Grasping at straws here.)

Good luck!

sarah adams
my son: http://clarkeadams.com
twitter: http://twitter.com/sarahwbs
portfolio: http://sarah.designshift.com

More information about the thelist mailing list