3

I have following type of error in codeigniter, I am unable solve it any one have idea what is cause of this error.

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at    /home/samples1/public_html/venture-test/application/controllers/admin/admin_notifications.php:158)

Filename: helpers/url_helper.php

Line Number: 540

I used two methods both are in same controllers as bellow.

 <?php
    public function approve_recent_user() {  
    $user_id = $this->uri->segment(4);
    $notification_id = $this->uri->segment(5);
    $status = 1;
    if($this->admin_notification_db->user_approve_flag($user_id,$status) == true) {
     redirect('admin/admin_notifications/unapproved_users');                
    }
    else {
        redirect('admin/admin_home');
    }
} ?>

after execution of this function I redirect on fo another methods as bellow.

<?php 
 public function unapproved_users() {        
    $result = $this->admin_notification_db->get_unapproved_users();
    $data['users'] = $result; 
    $this->load->view('admin/recent_users', $data); 
 } ?>
sangam
  • 171
  • 2
  • 4
  • 13
  • I checked the url_helper, at line number 540 this code is there case 'refresh' : header("Refresh:0;url=".$uri); – sangam Oct 11 '14 at 05:32

2 Answers2

8
Message: Cannot modify header information - headers already sent by (output started at    /home/samples1/public_html/venture-test/application/controllers/admin/admin_notifications.php:158)

The error occurs when you have started outputting anything before header redirect in PHP code. For example, check out any white spaces after or before PHP tags, HTML tags printing before starting of PHP tags or any output or debugging before the redirect function.

Please let me know further if you are still getting issues.

-1

use this instead for redirect. echo 'window.location="'.base_url().'your-page-name";';

Sajan Saj
  • 1
  • 4