0

Every time i run my module i am receiveing an php error like this but when i call the array using the print_r to look if that value is displayed it jsut display as i expected but, this why am i having a array to string convsersion?

A PHP Error was encountered
Severity: Warning

Message: Array to string conversion

Filename: database/DB_driver.php

and

An uncaught Exception was encountered
Type: mysqli_sql_exception

Message: Unknown column 'Array' in 'field list'

here is my code inside the one who starts to receive that error whenever i change the line quantity to save in the products table

public function update($id)
{
    if($id) {
        $user_id = $this->session->userdata('id');
        $user_data = $this->model_users->getUserData($user_id);
        // update the table info

        $order_data = $this->getOrderlistData($id);

        $stcode = 'STCODE-'.strtoupper(substr(md5(uniqid(mt_rand(), true)), 0, 4));
        $data = array(
            'st_code' => $stcode,
            'user_id' => $user_id,
            'status' => $this->input->post('status'),
            'remarks' => $this->input->post('remarks'),
        );

        $this->db->where('id', $id);
        $update = $this->db->update('orderlist', $data);

        // now remove the order item data 
        $this->db->where('orderlist_id', $id);
        $this->db->delete('orderlist_items');

        $count_product = count($this->input->post('product'));
        for($x = 0; $x < $count_product; $x++) {
            $items = array(
                'orderlist_id' => $id,
                'product_id' => $this->input->post('product'),
                'qty' => $this->input->post('qty')[$x],
                
            );

            $prodid = $this->input->post('product');

            //print_r($prodid);die;
            
            //$this->db->set('quantity', 'quantity+1', FALSE);
            //$this->db->where('id', $prodid);
            //$this->db->update('products');
            $product_quanti = array(
            'quantity' => $this->input->post('qty'),

            );
            //print_r($prodid);die;
            
            $update = $this->db->update('products', $product_quanti);
            

            $this->db->insert('orderlist_items', $items);
        }
        




        return true;
    }
}
wloleo
  • 1,294
  • 2
  • 6
  • 15
  • 1
    Can you confirm the data type of $this->input->post('qty'), $this->input->post('product'), $this->input->post('remarks') and $this->input->post('status')? It seems one of them is an array – Amir MB Dec 02 '22 at 17:41

0 Answers0