CodeIgniter错误号:1054“字段列表”中的未知列“ Array”。使用爆破

问题描述 投票:0回答:1
在列中插入图像名称

[请,我将多张图像移动到目标文件夹,并将图像名称插入由逗号分隔的单列中。这意味着,所有其他记录将被插入到一行一次,并且图像名称将被插入在由逗号分隔的列中。通过文件上传,可以很好地移动图像,但是数据不会插入数据库中。它在下面给出此错误:

遇到PHP错误

严重性:通知

消息:数组到字符串的转换

文件名:database / DB_driver.php

行号:1465

错误号:1054

[字段列表中的未知列'Array']

插入wzb_productWZB_ProductCodeProductGradeWZB_ProductNameWZB_ProductDescriptionWZB_QuantityPerUnitWZB_UnitPriceWZB_ProductOwnerWZB_CategoryNameWZB_VerifiedByAgentProductPhotoName,[C0 ])值('PR02_893','OLD','Giovani Vialli Shoe',Array,NULL,'350000','Admin','Bag And Shoe','NO','main-product01.jpg,main-product02 .jpg,main-product03.jpg,main-product04.jpg','')

事实是我没有名为Array的列。该表单使用TinyMCE允许用户键入产品描述。我怀疑图像文件名是罪魁祸首,或者可能是TinyMCE列(ProducrDescription)?

这是我执行的Controller方法:

Addedby

我没有使用模型。关键是,如果我插入一个不是多个图像的图像名称。它可以通过移动图像名称来正常工作,并且还可以将记录与图像文件名一起插入数据库,但是当它是多个图像时,我会收到此错误。

我感谢所有预先的努力。

问候,

[请,我将多张图像移动到目标文件夹,并将图像名称插入由逗号分隔的单列中。这意味着,所有其他记录将被插入到一行一次,并且...

php codeigniter-3
1个回答
0
投票

您在$filesCount = count($_FILES['productphotos']['name']); for($i = 0; $i < $filesCount; $i++) { $_FILES['file']['name'] = $_FILES['productphotos']['name'][$i]; $_FILES['file']['type'] = $_FILES['productphotos']['type'][$i]; $_FILES['file']['tmp_name'] = $_FILES['productphotos']['tmp_name'][$i]; $_FILES['file']['error'] = $_FILES['productphotos']['error'][$i]; $_FILES['file']['size'] = $_FILES['productphotos']['size'][$i]; $testprodpath = './Products/Old/BagShoes/'; //$uploadPath = './Products/'; //$uploadPath = base_url().'Products/'; $config['upload_path'] = $testprodpath; $config['allowed_types'] = 'gif|jpg|jpeg|png'; $config['max_size'] = '5000'; // max_size in kb $config['file_name'] = $_FILES['productphotos']['name'][$i]; $this->upload->initialize($config); //load upload library $this->load->library('upload', $config); //upload the files if($this->upload->do_upload('file')) { //Get data about the files $fileData = $this->upload->data(); $name_array[] = $fileData['file_name']; } // closes if else { echo $this->upload->display_errors(); } //closes else } //closes for loop $content = $this->input->post('content'); $datatiny['content'] = $content; $imagesnames= implode(',', $name_array); //Insert file information into the database $data2 = array( 'WZB_ProductCode'=>$this->input->post('productcode'), 'ProductGrade'=>$this->input->post('productgrade'), 'WZB_ProductName'=>$this->input->post('productname'), 'WZB_ProductDescription'=>$datatiny, 'WZB_QuantityPerUnit'=>$this->input->post('quantityperunity'), 'WZB_UnitPrice'=>$this->input->post('unitprice'), 'WZB_ProductOwner'=>$this->input->post('productowner'), 'WZB_CategoryName'=>$this->input->post('productcategory'), 'WZB_VerifiedByAgent'=>$this->input->post('verifiedbyagent'), 'ProductPhotoName'=>$imagesnames, 'Addedby'=>$this->input->post('addedby') ); $this->db->insert('wzb_product', $data2); $this->session->set_flashdata('Added Successfully','Record successfully added'); } //closes if for checking if file input has file is submitted and if file is uploaded 中有描述,并且在初始化中使用$datatiny['content']。它是数组,您不能在其中使用数组。因此,将行更改为:

© www.soinside.com 2019 - 2024. All rights reserved.