Welcome Guest, Not a member yet? Register   Sign In
[URI HELPER ERROR]Message: Cannot modify header information - headers already sent by (output started at C:\.......)
#1

[eluser]Ngulo[/eluser]
Hi all guys... i'm in trouble with redirect() in CI

i receive always this message:

Code:
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:....\site\application\models\download.php:2)

Filename: helpers/url_helper.php

Line Number: 541

i really can solve this problem , i don't know why it doesn't works :/

my code is so simple ,but seems that using $this->uri->segment() before a redirect() ,creates me this problem :/

this is my code:
Code:
function cd()
        {
            $id =  $this->uri->segment(3);
            if(is_numeric($id) and $id > 0 and $id < 6)
            {
            $date = date('d-m-o');
            $datetime = date('H:i:s');
            $ip = htmlentities($_SERVER['REMOTE_ADDR']);
            $this->load->model('download');
            $cd = $this->download->populateById($id);
            $disco_name = $cd->downloads_disco;
            $new_downloads_number = $cd->downloads_number + 1;
            //dat for update
            $data = array(
                'downloads_number'=>$new_downloads_number,
                    );
            $updateDownloadsNumber = $this->download->update($id,$data);
            unset($data);
            $this->load->model('downloaddetails');
            $data = array(
                'id_downloads_details'=>$id,
                'ip_downloads_details'=>$ip,
                'date'=>$date,
                'datetime'=>$datetime
            );
            $this->downloaddetails->insert($data);
            
             redirect(base_url().'/downloads/cd/'.$disco_name.'.rar');
            }
            else{ exit;}
        }

it's so simple my function ,that i really can't understand the reason why it doesn't works

any suggestions ? Tongue

really thanks guys Wink
#2

[eluser]mi6crazyheart[/eluser]
Hey , the error is coming from u'r model file: download.php . So, i think the problem is might be at there. Check it once again...
#3

[eluser]Ngulo[/eluser]
mi6crazyheart oh my god you're right!
Although the problem remains because in model download.php on line 2 I can not find errors: /

this is the model, and frankly I'm going crazy because of their mistakes do not find them: /

Do you see anything strange?

Code:
&lt;?php  if(!defined('BASEPATH')) exit('No direct script access allowed'); ?&gt;
&lt;?php
class Download extends Model {

  function insert($data)
  {
    $this->db->insert('khc_downloads',$data);
  }
  function populate()
  {
    $query = $this->db->get('khc_downloads');
    return $query->result();
  }
  function populateById($id)
  {
    $query = $this->db->where('id_downloads',$id)->get('khc_downloads');
    
    return $query->row();

  }


function update($id,$data)
{

$this->db->where('id_downloads', $id);
$this->db->update('khc_downloads', $data);
return;
}

  function delete($id)
  {
      $this->db->where('id', $id);
      $this->db->delete('khc_download');

      return;
  }
}

thanks so much for the help Wink
#4

[eluser]victorche[/eluser]
Please, check the double
Code:
&lt;?php
Closing and opening is useless for me and maybe this is the problem.
So this:
Code:
&lt;?php  if(!defined('BASEPATH')) exit('No direct script access allowed'); ?&gt;
&lt;?php
Can be:
Code:
&lt;?php  if(!defined('BASEPATH')) exit('No direct script access allowed');
Maybe?
#5

[eluser]Ngulo[/eluser]
yeah man i solve the problem Smile

than ks really thanks Wink




Theme © iAndrew 2016 - Forum software by © MyBB