Javascript codeigniter复选框内爆功能错误

Javascript codeigniter复选框内爆功能错误,javascript,php,html,codeigniter,Javascript,Php,Html,Codeigniter,这是我的看法 <input type="text" name="name" class="form-control" placeholder="name" /> <div class="col-sm-12"> <select name="speciality" class="form-control" required > <option value="" selected="selected" >Liste specia

这是我的看法

<input type="text" name="name" class="form-control" placeholder="name" />
<div class="col-sm-12">
    <select name="speciality"  class="form-control" required >
        <option value="" selected="selected" >Liste speciality</option>
        <option value="ag" >spec1</option>
        <option value="al" >spec2</option>
        <option value="pvc">spec3</option>
        <option value="MEDC">spec4</option>
    </select>
</div>

<div class="col-sm-9">
    <label class="checkbox-inline">
        <input type="checkbox"  value="parquet" name="products[]">
        product1
    </label>

    <label class="checkbox-inline">
        <input type="checkbox"  value="fplancher" name="products[]">
        product2
    </label>

    <label class="checkbox-inline">
        <input type="checkbox"  value="fauxplafonddem" name="products[]">
        product3
    </label>

    <label class="checkbox-inline">
        <input type="checkbox"  value="cloison" name="products[]">
        product4 
    </label>

    <label class="checkbox-inline">
        <input type="checkbox"  value="cloisonamovible" name="products[]"> 
        product5 
    </label>

    <div class="bottom">
        <button class="btn btn-primary" name="btnAdd" value="1"  type="submit"> <i class="fa fa-mail-reply-all"> &nbsp;save</i> </button>
        <button class="btn btn-default" type="reset" > <i class="fa fa-ban">&nbsp;cancel</i></button>
    </div>
</div>

李斯特特产
规格1
规格2
规格3
规格4
产品1
产品2
产品3
产品4
产品5
拯救
取消
这是我的控制器

public function add() {
         $prod=implode(',',$this->input->post('products'));
           $data=array('nomsoc'=>$this->input->post('name'),
                    'specialitesoc'=>$this->input->post('speciality'),
                    'produitssoc'=>$prod);
           if ($this->input->post("btnAdd", false))
            { 
            if($this->SocieteModel->add($data))
                {
                $this->session->set_flashdata('message', 
                '<div class="alert alert-success" role="alert">Société ajoutée avec succès </div>');
                redirect("/societe/");
            } 

       }
    $this->layout->title(' campany Title'); // Set page title
                $this->LoadViewBlocks("societe","","",true,true,true);
                $data["bodyId"]="register-bg";
                $this->layout->view('backend/societe/add', $data);
        }
公共函数添加(){
$prod=内爆(',',$this->input->post('products');
$data=array('nomsoc'=>$this->input->post('name'),
'specialitesoc'=>this->input->post('speciality'),
‘produitssoc’=>$prod);
如果($this->input->post(“btnAdd”,false))
{ 
如果($this->SocieteModel->add($data))
{
$this->session->set_flashdata('消息'),
"兴业银行";;
重定向(“/societe/”);
} 
}
$this->layout->title('campany title');//设置页面标题
$this->LoadViewBlocks(“societe”、“”、“”、true、true、true);
$data[“bodyId”]=“寄存器bg”;
$this->layout->view('backend/societe/add',$data);
}
加载视图以添加新的campany时,出现错误:

遇到一个PHP错误 严重性:警告消息:内爆():传递的参数无效 电话号码:41

任何人都可以帮忙

  • 遇到PHP错误严重性:警告消息:内爆():传递的参数无效行号:41
  • 如果
    $this->input->post('products')
    值为空或不是数组,则会出现上述错误。确保你有数组值

  • 我已经试过你的代码了。它只工作得很好。请仔细检查一下

    我使用了这个查看页面

    <form action="<?php echo base_url(); ?>index.php/forms/add" method="post"><input type="text" name="name" class="form-control" placeholder="name" />
      <div class="col-sm-12">
         <select name="speciality"  class="form-control" required >
                 <option value="" selected="selected" >Liste speciality</option>
                 <option value="ag" >spec1</option>
                 <option value="al" >spec2</option>
                 <option value="pvc">spec3</option>
                 <option value="MEDC">spec4</option>                     
         </select>
      </div>
        <div class="col-sm-9">
           <label class="checkbox-inline">
             <input type="checkbox"  value="parquet" name="products[]">
              product1</label>
            <label class="checkbox-inline">
             <input type="checkbox"  value="fplancher" name="products[]">    product2</label>
         <label class="checkbox-inline">
         <input type="checkbox"  value="fauxplafonddem" name="products[]">
                    product3</label>
                    </div>
                    <label class="checkbox-inline">
                     <input type="checkbox"  value="cloison" name="products[]">
                                   product4 </label>
                     <label class="checkbox-inline">
                      <input type="checkbox"  value="cloisonamovible" name="products[]"> product5 </label>
         <div class="bottom">
         <button class="btn btn-primary" name="btnAdd" value="1"  type="submit"> <i class="fa fa-mail-reply-all"> &nbsp;save</i> </button>
         <button class="btn btn-default" type="reset" > <i class="fa fa-ban">&nbsp;cancel</i></button>
                    </div>
    
                    </form>
    

    如果使用双qoutes会发生什么$prod=内爆(“,”,$this->input->post('products');双引号存在相同问题您使用相同的方法加载添加视图并保存添加视图?打印($this->input->post('products');在使用内爆poria之前看看它是否是一个数组,在哪里放置print_r($this->input->post('products')?当我使用打印($data)时,它显示数组([nomsoc]=>[specialitesoc]=>[ProduitSoc]=>[ActiviteSoc]=>[DirigentSoc]=>[telsoc]=>[faxsoc]=>[ville]=>[AdresSoc]=>[facebooksoc]=>[twittersoc]=>[linkedinsoc]=>[youtubesoc]=>[emailsoc]=>)你在查看文件中做了什么更改吗?输入类型=“复选框”值=“cloisonamovible”name=“products[]”>product5放置开放标签。我的视图中存在,我没有更改任何内容您是否将开放标签放置在prodcuts复选框中。
    
    public function add() {
             $prod=implode(',',$this->input->post('products'));
               $data=array('nomsoc'=>$this->input->post('name'),
                        'specialitesoc'=>$this->input->post('speciality'),
                        'produitssoc'=>$prod);
               print_r($data); exit();
               if ($this->input->post("btnAdd", false))
                { 
                if($this->SocieteModel->add($data))
                    {
                    $this->session->set_flashdata('message', 
                    '<div class="alert alert-success" role="alert">Société ajoutée avec succès </div>');
                    redirect("/societe/");
                } 
    
           }
                    $this->layout->title(' campany Title'); // Set page title
                    $this->LoadViewBlocks("societe","","",true,true,true);
                    $data["bodyId"]="register-bg";
                    $this->layout->view('backend/societe/add', $data);
        }