954,176 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

include(); problem

Hi,
I have a file with the dbase connection details which I call into my script using: include("config.php");

Problem is that when I need to include a page redirection, namely:
header("Location: other_page.php");

I get an error saying that headers were already sent from the line with the include("config.php");

How do i get around this so I don't have to write out the dbase connections everytime I need to have a
header("Location: other_page.php");
thanks.

michael123
Junior Poster in Training
94 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

I assume you already checked to make sure config.php does not actually echo or print anything to the buffer!

Look at your closing ?>. Is there a blank line after it? I've seen this cause the problem you describe. Delete anything after the closing tag. Also, if you are using PHP on Linux, make sure your files use Linux style line endings.

Troy
Posting Whiz
362 posts since Jun 2005
Reputation Points: 36
Solved Threads: 6
 

Thanks, Troy.

michael123
Junior Poster in Training
94 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You