-1
發送的標頭
即使我將某些東西插入到數據庫中,但它會導致數據錯誤但我收到此錯誤時會出現此錯誤消息:無法修改標頭信息 - 標頭已由(輸出開始在項目/應用/控制器/ add_products.php:79)codeigniter錯誤消息:無法修改標頭信息 - 已由
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));
$query = 'INSERT INTO product_category (id , category) VALUES (? , ?)
ON DUPLICATE KEY UPDATE category=VALUES(category)';
$this->User->insert_prod($file);
$data = array('upload_data' => $this->upload->data());
echo '<script>alert("You Have Successfully Added a new Product!");</script>';
redirect('admin_products','refresh');
$this->load->view('admin_products');
}
}
可能的複製[如何解決「頭已經發送」錯誤在PHP( http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – Qirel