Hello:

I'm trying to make a form field which is a checkbox be sticky.

For starters, did I correctly code the checkbox for it to be sticky?

When I run the script, I'm receiving this message:
Parse error: syntax error, unexpected ';'
and I can't seem to find the problem.

This is the line of code causing the problem:

<input type="checkbox" name="availability[]" id="availability" value="Weekday Mornings"<?php echo (isset ($_SESSION['availability']) && $_SESSION['availability'] == 'Weekday Mornings' ? ' checked="checked"' : ''; ?> />Weekday mornings<br>

I do have the variable validated in the beginning of the script. Everything works fine but when I started to make the fields sticky, the checkbox field doesn't want to remain checked.

This is my validation code:

if (isset($_POST['availability']) && (is_array($_POST['availability']))) {
      $_SESSION['availability'] = TRUE;
   } else {
     $errors[] = 'Availability is a required field, Please select at least one.';
   }

Thanks for all the help.

    You're missing the ) that matches the ( before isset. Either that or that ( shouldn't be there.

    As for the other question: should $_SESSION['availability'] be equal to 'Weekday Mornings' (as it is being tested for in the first excerpt), or should it be equal to true (as it is being set in the second excerpt)?

      Write a Reply...