我昨天一整天都收到警告错误,无法将其关闭。不知道发生了什么。它抱怨在第 1 行对 property_model.php 执行重定向之前发送了一些输出。我去那里检查了所有内容,但没有运气。我还检查了空格。我将粘贴错误和代码。
遇到 PHP 错误
严重性:警告
消息:无法修改标头信息 - 标头已发送(输出开始于 /home/sddhd/public_html/rsw/application/models/property_model.php:1)
文件名:helpers/url_helper.php
行号:542
现在上面显示的模型代码是:
<? class Property_model extends CI_Model {
function __construct()
{
parent::__construct();
}
function insert_property($propertyID)
{
$this->property_id = $propertyID;
$this->type = $_POST['property_type'];
$this->city = $_POST['property_city'];
$this->address = $_POST['property_address'];
$this->description = $_POST['property_description'];
$this->owner = $_POST['property_owner'];
$this->date_added = date("Y-m-d");
$this->price = $_POST['property_price'];
$this->offer_type = $_POST['property_offer'];
$this->contact = $_POST['property_contact'];
$this->db->insert('property', $this);
}
function insert_image_details($id, $url, $extension)
{
$current->property_id = $id;
$current->extension = $extension;
$current->url = $url;
$this->db->insert('photos', $current);
}
}
?>
以及重定向调用的用途(包括对模型的整个控制器调用):
<?php
class Property extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper('form');
$this->load->helper('url');
$this->load->model('property_model', 'propertymodel');
$this->load->database();
}
public function index() {
$this->load->view('home');
}
public function new_property()
{
$this->load->view('new_property', array('error' => '' ));
}
public function create_property()
{
//Pass the posted data to model for insertion
$propertyID = uniqid();
$this->propertymodel->insert_property($propertyID);
$this->do_upload($propertyID);
redirect('/home');
}
public function do_upload($propertyId)
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('create_property', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
//array to access all the file uploaded attributes
$image_data = $this->upload->data();
//parameters to be passed to model:
$imgUrl = "../.".$config['upload_path'].$image_data['file_name'];
//$imgTitle = $image_data['file_name'];
$fileExtension = $image_data['file_ext'];
$this->propertymodel->insert_image_details($propertyId, $imgUrl, $fileExtension);
}
}//end of function
}
?>
任何帮助将不胜感激