Christian February 2016

codeigniter error Message: Cannot modify header information - headers already sent by

im getting this error whenever i insert something into the database it insters the data but i recieve this error Message: Cannot modify header information - headers already sent by (output started at project/application/controllers/add_products.php:79)

function do_upload() {
        $config['upload_path'] = './assets/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '2000';
        $config['max_width'] = '2000';
        $config['max_height'] = '2000';
        $config['new_image'] = './assets/';

        $config['overwrite'] = TRUE;
        $this->load->library('upload', $config);
        $this->form_validation->set_rules('name', 'Product Name', 'required|xss_clean');
        $this->form_validation->set_rules('description', 'Product Description', 'required|xss_clean');
        $this->form_validation->set_rules('price', 'Price', 'required');
        if (!$this->upload->do_upload() || !$this->form_validation->run()) {
            $error = array('error' => $this->upload->display_errors());
            redirect('add_products');
        } else {

            $data = $this->upload->data();
            $this->thumb($data);

             $category = $_POST["prod_category"];
            if($category  == "2")
                {
        $category = $_POST["other_category"];
            }
            $file = array(
                'img_name' => $data['raw_name'],
                'thumb_name' => $data['raw_name'] . '_thumb',
                'ext' => $data['file_ext'],
                'product_name' => $this->input->post('name'),
                'product_description' => $this->input->post('description'),
                'product_price' => $this->input->post('price'),
                'product_category' =>$category,    


            );

             // $this->db->insert("product_category",array("category"=>$category));
                    

Answers


dhruv jadia February 2016

remove line

echo '<script>alert("You Have Successfully Added a new Product!");</script>';

Post Status

Asked in February 2016
Viewed 2,439 times
Voted 9
Answered 1 times

Search




Leave an answer