Ошибка argument 1 is not an array in

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']);
}

John Conde's user avatar

John Conde

217k99 gold badges455 silver badges496 bronze badges

asked Sep 9, 2013 at 19:43

acctman's user avatar

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']);

answered Sep 9, 2013 at 19:44

John Conde's user avatar

John CondeJohn Conde

217k99 gold badges455 silver badges496 bronze badges

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.

answered Sep 9, 2013 at 19:45

Sven's user avatar

SvenSven

69k10 gold badges105 silver badges108 bronze badges

Получаю ошибку:

PHP Warning:  array_merge(): Argument #1 is not an array in

Вот код:

$array = array('info' => $_POST["Info"]);
$array = array_merge($array, array('data' => '<span style="color:green ">Yes</span>'));


  • Вопрос задан

    более двух лет назад

  • 279 просмотров

Этот код не должен вызывать эту ошибку. Проверяйте, возможно вы изменения на сервер не залили или типа того.
А может ошибка генерируется в другом месте. проверьте номер строки в ошибке.

Пригласить эксперта

Сути это не изменит, но попробуйте вот так:

$array = ['info' => $_POST["Info"]];
$array = array_merge($array, ['data' => '<span style="color:green ">Yes</span>']);


  • Показать ещё
    Загружается…

13 июн. 2023, в 14:15

50000 руб./за проект

13 июн. 2023, в 14:03

5000 руб./за проект

13 июн. 2023, в 14:02

1200 руб./в час

Минуточку внимания

I (also) noticed the same error in a third party plugin (LifterElements) after updating to 2.9.1.

In my case, the error seems to happen when using the «update_control» method on a widget.

For what I saw, the error happens only if I change the type of a control.

For example, this will result to the error:

$control = $element->get_controls( $name );
$control['type'] = ElementorControls_Manager::HIDDEN;
$element->update_control( $name, $control );

But this will not:

$control = $element->get_controls( $section_id );
$control['conditions'] = [
  'terms' => [
    [
      'name' => 'render_type',
      'operator' => 'in',
      'value' => [ 'custom_button'],
    ],
  ]
];
$element->update_control( $section_id, $control );

I hope it will help!

In Drupal 7, I’m getting this error and want to fix it:

  • Warning: array_merge() [function.array-merge]: Argument #1 is not an array in _form_set_class() (line 4021 of {my site}/includes/form.inc).
  • Warning: array_merge() [function.array-merge]: Argument #1 is not an array in _form_set_class() (line 4021 of {my site}/includes/form.inc).
  • Warning: implode() [function.implode]: Invalid arguments passed in theme_radios() (line 2746 of {my site}/includes/form.inc).

What does this mean, and what should I do about it?

apaderno's user avatar

apaderno

96.2k15 gold badges157 silver badges283 bronze badges

asked Jan 23, 2012 at 4:56

oobie11's user avatar

2

For me it happened; when I used

$form['field']['#attributes'] = array('class' => 'myclass');

While it should be

$form['field']['#attributes'] = array('class' => array('myclass'));

answered May 5, 2012 at 6:08

Sivaji's user avatar

SivajiSivaji

2,4761 gold badge21 silver badges30 bronze badges

There’s likely a buggy FAPI definition. Are you developing a form? If so, check your form definition. It’s not being returned as an array.

answered Jan 23, 2012 at 7:17

BetaRide's user avatar

BetaRideBetaRide

5,36821 silver badges32 bronze badges

So i figured it out, I wasn’t sure what I had done to make this start happening, but it was being caused by the «Drupal for Facebook» module. It was only popping up when I was on a node edit page strangely. For those familiar, I had the «FB User Management» enabled and after disabling, it stopped giving me the error.

answered Jan 23, 2012 at 8:33

oobie11's user avatar

oobie11oobie11

1,1001 gold badge17 silver badges26 bronze badges

I got the same error and got rid of it by changing the subscription.module at line#514…:

      $headers = array(t('type'), t('title'), t('operations'));
      	$subrows = array_merge($subrowsn, $subrowsb, $subrowst);

to

      $headers = array(t('type'), t('title'), t('operations'));
      	if (!is_array($subrowsn)) $subrowsn=array();
      	if (!is_array($subrowsb)) $subrowsb=array();
      	if (!is_array($subrowst)) $subrowst=array();
      	$subrows = array_merge($subrowsn, $subrowsb, $subrowst);

just like Bernd, who has it done with the similar array problem (http://drupal.org/node/24151).

I do not know, if there will be later any trouble.. but for the moment, it seems to work.

greets, Shezz

Возможно, вам также будет интересно:

  • Ошибка application load error 5 0000065434 черные бушлаты
  • Ошибка api ms win synch l1 2 0 dll
  • Ошибка argument 1 has unexpected type nonetype
  • Ошибка application load error 5 0000065434 как исправить
  • Ошибка api ms win eventing classicprovider

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии