I'm receiving the following error Warning: array_merge(): Argument #1 is not an array when processing $_POST['cpl']
, although $_POST['add']
works fine
if (is_array($_POST['add'])) {
foreach ($_POST['add'] as $key => $value) $_POST['add'][$key] = mysql_real_escape_string($value);
$en = array_merge($en, $_POST['add']);
}
if (is_array($_POST['cpl'])) {
foreach ($_POST['cpl'] as $key => $value) $_POST['cpl'][$key] = mysql_real_escape_string($value);
$cp = '';
$cp = array_merge($cp, $_POST['cpl']);
}
That's because $cp
is a string (you explicitly defined it that way).
$cp = ''; // <-- empty string
$cp = array_merge($cp, $_POST['cpl']);
should be:
$cp = array(); // <--now it's an array
$cp = array_merge($cp, $_POST['cpl']);
You have these lines:
$cp = '';
$cp = array_merge($cp, $_POST['cpl']);
It's self-explanatory: $cp
is a string first, the error is simply about this fact. Initialize it with array()
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With