douren6874 2012-07-11 21:01
浏览 41

codeigniter:为什么这个模型发出codeigniter会话相关的严重警告问题?

here is the model:

    <?php

class Generalfeaturesmodel extends CI_Model      
{              
    protected $websitename;            

    public function __construct()                                   
    { 
        parent::__construct();
        $this->websitename = 'GameSwap';   
    } 

    // helper function that retrieves all the data from the specified table.  Basically since this is in the swap account model
    // only use it for swap account related tables, not membership related tables for instance.
    public function getdetails($tablename)
    {
        $query = $this->db->get($tablename);  
        $allrows = array();
        $i=0;
        foreach($query->result_array() as $row) 
        {
            $allrows[$i++]=$row;
        }
        return $allrows;       
    } 

    // returns all the games based on the query conditions.
    // @conditions - an associative array containing the conditions for the query.
    // returns an array with all the games based on the where clauses.
    public function gettargetswaps($where)  
    {      
        $query = $this->db->get_where('swaps',$where);
        $targetswaps = array(); 
        $i = 0; 
        foreach($query->result_array() as $s)  
        { 
            $query = $this->db->get_where('games',array('id'=>$s['gameid'])); 
            $details = $query->row_array();
            $gamedetails = array('name'=>$details['name'],'consoleid'=>$details['consoleid'],'genreid'=>$details['genreid'],'imgurl'=>$details['imgurl']);
            $targetswaps[$i] = array_merge($s,$gamedetails); 
            $i++;  
        } 
        return $targetswaps;
    }
}   
?>   

basically heres is the error i get when i load the above model:

A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/phpgod/public_html/johnnyarias/ci_website/application/models/generalfeaturesmodel.php:50)
Filename: libraries/Session.php
Line Number: 672

and here is the function in the Session.php file thats throwing/or has to do with the error:

function _set_cookie($cookie_data = NULL)
{
    if (is_null($cookie_data))
    {
        $cookie_data = $this->userdata;
    }

    // Serialize the userdata for the cookie
    $cookie_data = $this->_serialize($cookie_data);

    if ($this->sess_encrypt_cookie == TRUE)
    {
        $cookie_data = $this->CI->encrypt->encode($cookie_data);
    }
    else
    {
        // if encryption is not used, we provide an md5 hash to prevent userside tampering
        $cookie_data = $cookie_data.md5($cookie_data.$this->encryption_key);
    }

    $expire = ($this->sess_expire_on_close === TRUE) ? 0 : $this->sess_expiration + time();

    // Set the cookie
    setcookie(
                $this->sess_cookie_name,
                $cookie_data,
                $expire,
                $this->cookie_path,
                $this->cookie_domain,
                $this->cookie_secure
            );
}

And line 50 in the Generalfeaturesmodel is the end of the file(right after the '?>' php tag)...I have no idea what could be going wrong here???

  • 写回答

1条回答 默认 最新

  • dongsimang4036 2012-07-25 05:47
    关注

    Also appears to be a tab space in front of your <?php and as Damien mentioned, it is safer to leave the closing ?> so there is no output in the event a newline is saved at the end of the file

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类