Warning: Invalid argument supplied for foreach() line 64
Foreach can only take arrays. If only one item is sent, it will be sent as a single [string or other] variable, not as an array.
This is the most common reason for the error. Since I'm not entirely positive about what the variable is at that point (only testing live would show this), this IS just a guess, but I believe it will fix it.
In other words, you will get two types on input and you must use a foreach loop for them.
Here's a one line piece of code to add that will fix that:
Place this immediately before the foreach loop:
Code:
if (!is_array($_POST['patrol'])) { $_POST['patrol'] = array($_POST['patrol']); }
Some notes:
1. I don't know if it will ever actually be an array, but this will fix the foreach loop. Only in rare cases will you actually get an array sent from a form-- it's possible, though. I'd suggest reading up on this unless you're sure, so you know what to expect.
2. It's much better to not use $_POST or $_GET variables directly within your script. It's better to rename them to a regular variable before modifying them (so my code is messy in this sense). So at the start use $x = $_POST['x']; and work from there, not from $_POST['x'].
Bookmarks