Php 消息:内爆():在codeigniter中传递的参数无效

Php 消息:内爆():在codeigniter中传递的参数无效,php,jquery,codeigniter,Php,Jquery,Codeigniter,代码: 在这段代码中,我有一个表单,其中我使用jquery/ajax插入表单值,但当我使用内爆函数时,它会引发一条错误消息,即 $item_des = implode(',',$this->input->post('item_des')); $item_cost = implode(',',$this->input->post('item_cost')); $service_cost = implode(',',$this->input->post('serv

代码:

在这段代码中,我有一个表单,其中我使用jquery/ajax插入表单值,但当我使用内爆函数时,它会引发一条错误消息,即

$item_des = implode(',',$this->input->post('item_des'));
$item_cost = implode(',',$this->input->post('item_cost'));
$service_cost = implode(',',$this->input->post('service_cost'));
$total_cost = implode(',',$this->input->post('total_cost'));

$data = array(
            'item_des' => $item_des,
            'item_cost' => $item_cost,
            'service_tax' => $service_cost,
            'total_cost' => $total_cost,
            );

            print_r($data);
$query = $this->db->insert('table_name',$data);
那么,我如何解决这个问题?请帮助我


谢谢

试着打印每个变量

Message: implode(): Invalid arguments passed
很可能这些字段不是数组。你有隐藏字段吗?或者您的html应该如下所示:

var_dump($this->input->post('name')); //all these should be array


现在HTML将在post中返回一个数组。请使用数组将其转换为字符串。

尝试打印每个变量

Message: implode(): Invalid arguments passed
很可能这些字段不是数组。你有隐藏字段吗?或者您的html应该如下所示:

var_dump($this->input->post('name')); //all these should be array


现在HTML将在post中返回一个数组。请期望数组将其转换为字符串。

您可以将$a转换为数组,以确保在使用内爆时始终使用数组

<input name="item_des[]" /> <!-- name should be an array instead of a string name, as shown here -->
<input name="item_des[]" /> <!-- there could be multiple inputs for each of the array you want to `implode` -->
在哪里,

implode(',', (array) $a);

其他情况也是如此。试试这个,它肯定会跑的

您可以将$a转换为数组,以确保在使用内爆时始终使用数组

<input name="item_des[]" /> <!-- name should be an array instead of a string name, as shown here -->
<input name="item_des[]" /> <!-- there could be multiple inputs for each of the array you want to `implode` -->
在哪里,

implode(',', (array) $a);

其他情况也是如此。试试这个,它肯定会跑的

此错误意味着您的变量未定义或不是数组。 在处理数据之前,请确保它们的定义与您认为的一致

您可以使用来确保定义了变量并确保它们是数组。一旦你知道了你的变量是什么,你就可以按照他们应该的方式来处理它们(可能是因为你期望一个正确定义的数组)


将它们转换到数组中对您没有帮助,因为这意味着数据不是您所期望的。如果您的代码可能会有进一步的问题,则返回其余部分。

此错误意味着您的变量没有定义或没有数组。 在处理数据之前,请确保它们的定义与您认为的一致

您可以使用来确保定义了变量并确保它们是数组。一旦你知道了你的变量是什么,你就可以按照他们应该的方式来处理它们(可能是因为你期望一个正确定义的数组)


将它们转换到数组中对您没有帮助,因为这意味着数据不是您所期望的。如果您的代码可能会有其他问题。

这个问题可以解决,但是与将多个值存储在csv字符串的同一列中有关的更大问题呢?您的post变量是否为数组?函数用于转换字符串中的数组。您的变量可能不是数组…这个问题可以解决,但是与将多个值存储在同一列中作为csv字符串有关的更大问题呢?您的post变量是否为数组?函数用于转换字符串中的数组。您的变量可能不是数组…我希望这有帮助:)是的,这会有帮助,但我非常确定CI返回数组的原样,如果您通过
$this->input->post()获取它(I)$this->input->post('item_des')input->post()$this->input->post();类似于$_POST[];现在,如果在$\u POST中传递一个键,它将返回该特定键中的字符串。例如:$_POST['key1'];这将返回key='key1'处的字符串,我希望这有帮助:)是的,这会有帮助,但我非常确定,如果您通过
$This->input->post()获取数组,CI将返回原样的数组(I)$this->input->post('item_des')input->post()$this->input->post();类似于$_POST[];现在,如果在$\u POST中传递一个键,它将返回该特定键中的字符串。例如:$_POST['key1'];这将返回key='key1'处存在的字符串