0

I have this known issue:

This is my Controller:

 <?php
 ob_start();
 if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 class AddScore extends CI_Controller
{
    //Constructor
      function __construct() {
          parent::__construct();
          $this->load->helper ( 'url' );
          $this->load->helper ( 'form' );

      }


      function AddToDatabase()
      {
          $userName=$_GET['userName'];
          $userID=$_GET['userID'];
          $score=$_GET['score'];
          $this->load->model('module/ProductsModel'); 
          $this->UserScoresModule->AddUserScore($userID,$userName,$score); 
          // $data=array('ID' => $_GET['ID'], 'Name' => $_GET['Name']);
          // $this->load->view ( 'SupplierAllProductsView',$data);
      }

}

In a post here in Stackoverflow a guy suggested to use ob_start();, so I add it in my code, but the problem remains.

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /hermes/bosweb25a/b500/ipg.spaghetticodestudioc/TDDD27/application/controllers/AddScore.php:1)

Filename: core/Common.php

Line Number: 438

Any idea what I am missing?

halfer
  • 19,824
  • 17
  • 99
  • 186
Avraam Mavridis
  • 8,698
  • 19
  • 79
  • 133
  • 1
    Using `ob_start` would cover up the problem rather than fix it. Instead, look at "AddScore.php" at the start of the file - you probably have a carriage return, space or tab before your ` – halfer Oct 19 '13 at 07:20

1 Answers1

1

You have whitespace before <?php, at least in the code you posted.

The server is sending the whitespace as HTML content to the client, i.e. output. It automatically adds headers before it sends it, therefore "headers already sent".

Tim
  • 6,281
  • 3
  • 39
  • 49