Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Headers already sent

Status
Not open for further replies.

patrickstrijdonck

Programmer
Jan 18, 2009
97
0
0
NL
Hi all,

im trying to let a hyperlink work, when that is clicked the page checkstatus.php will open containing this code

Code:
<?php
session_start();

include 'dbc.php';
$useremail = $_SESSION['user'];


$result = mysql_query("SELECT rayon, bedrijf, cursus FROM users WHERE user_email = '$user_email'");
while($row = mysql_fetch_array($result))
{
	$rayonon = $row['rayon'];
	$bedrijfon = $row['bedrijf'];
	$cursuson = $row['cursus']	;	
			
			
			
		
			if ( $rayonon == 1 ) {
	header("Location: rayon.php");
	exit();
} else {
	;
}

			if ( $bedrijfon == 1 ) {
	header("Location: bedrijf.php");
	exit();
} else {
	;
}

			if ( $cursuson == 1 ) {
	header("Location: cursus.php");
	exit();
} else {
	;
}
	}		
		
		exit();
    
?>

when i try the page i get this error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/cmict/domains/cmict.nl/public_html/bhv/checkstatus.php:2) in /home/cmict/domains/cmict.nl/public_html/bhv/checkstatus.php on line 3

what im trying to do is; php must get a record from the mysql database, a record similiar to the users emailadres, wich is
Code:
 $_SESSION['user']
after that is done, php must decide wich off the 3 fields is "1", is a field is "1" it must open the right php file.

I tried to mess with the code but all i can get is this error or an empty page...... whole blank page.


Can someone help me with this??

Greetz

Patrick
 
you will have a line break or some other blank white space before the <?php in this file.

php interprets this as html and sends it back via the webserver to the browser. once text has been sent to the browser, html headers are 'closed' (i.e. no more can be sent), and session_start() relies on being able to set a cookie on the client machine. Cookies, of course, are set through the header and so you can see why php gets upset!
 
well <?php started at line 2 so i removed line 1 and the error is gone
but still the page is empty and its not going to 1 of the 3 pages:(

 
o this is funny....

solved it:D

problem is: the $useremail was correct but the mysql query was looking for $user_email

stupid...

but it solved the problem.

Thanks for any help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top