Possible Duplicate:
Headers already sent by PHP
My problem is that I have a class with a function inside of it, and I get;
Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/inc/class.php:105) in /home/user/public_html/inc/facebook/login.php on line 21
When the page I’m using it on redirects a user with the header(); tag. The class is;
class mysql {
private $user;
private $pass;
private $db;
public function __construct($user1, $pass1, $db1) {
$this->user = $user1;
$this->pass = $pass1;
$this->db = $db1;
$this->connect();
}
public function connect() {
$this->connection = mysql_connect('localhost', $this->user, $this->pass);
$select = mysql_select_db($this->db, $this->connection);
}
public function query($x) {
return mysql_query($x);
}
public function fetch($x) {
return mysql_fetch_array($x);
}
public function num($x) {
return mysql_num_rows($x);
}
}
Line 105 is the;
return mysql_fetch_array($x);
And the file trying to do the header redirect just includes this file at the top of the page and does the header lower down.
Thanks in advance.
That’s the problem. You need to put
ob_start();right at the beginning of the file withheader();.