gpt4 book ai didi

php - codeigniter 空格或 header 导致警告

转载 作者:行者123 更新时间:2023-12-02 22:24:17 25 4
gpt4 key购买 nike

我昨天一整天都在收到警告错误,无法解决。不知道发生了什么。它提示说在第 1 行对 property_model.php 执行重定向之前发送了一些输出。我去那里检查了所有内容但没有运气。我还检查了空格。我将粘贴错误和代码。

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/sddhd/public_html/rsw/application/models/property_model.php:1)

Filename: helpers/url_helper.php

Line Number: 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);
}
}
?>

以及重定向调用的使用(包括对模型进行调用的整个 Controller 调用):

<?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


}
?>

任何帮助将不胜感激

最佳答案

我遇到了同样的问题。没有任何帮助。然后我决定创建一个完整的新文件,并将导致错误的文件中的内容复制到新文件中。这奏效了!显然原始文件在位置 0 处有一个隐藏字节。

关于php - codeigniter 空格或 header 导致警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13190835/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com