Jump to content

PHP headers already sent out.

VortexS
Go to solution Solved by Ciccioo,

you can only use the header() function if there has been no output yet

so, from the moment you print/echo something, any header() call will fail

your code outputs 3 tabs before executing the script, which invalidates the header() call

Hello guys,

 

I'm having a little trouble with my site I'm working on for school.

When I want to choose a stylesheet, and press apply ( you can test it here: http://s1081065.iie.nl/oop_s1081065/view/admin_config.php) I get the following error: 

 

Warning: Cannot modify header information - headers already sent by (output started at /home/s1081065/domains/s1081065.iie.nl/public_html/oop_s1081065/controller/configurationController.php:1) in /home/s1081065/domains/s1081065.iie.nl/public_html/oop_s1081065/controller/configurationController.php on line 15

 

Code of configurationController.php looks like this: http://i.imgur.com/ILjSjxf.png

 

I just want the header to sent me back to the homepage after applying, and I can't find the mistake I'm making.

If any other files are neccesary to look at, I can post the code of them as well.

Mah Build:  CPU: Intel i7-7700K COOLING: NZXT Kraken X52 GPU: Asus Strix GTX 1080 MOBO: Asus Strix Z270F RAM: 16GB GSKILL TridentZ RGB 3000 

CASE: In Win 303 STORAGE: Samsung 850 EVO 250GB, Seagate 1TB  SSHD PSU: EVGA Supernova G2 750W

Link to comment
Share on other sites

Link to post
Share on other sites

Copy/paste the code within [ code]

tags (remove the space.) A picture doesn't particularly help us as 1 - No one is gonna write it all out to modify and potentially fix, if they don't know the solution already. 2 - We may not be able to see the entire contents of the file and/or access Imgur.

Link to comment
Share on other sites

Link to post
Share on other sites

you can only use the header() function if there has been no output yet

so, from the moment you print/echo something, any header() call will fail

your code outputs 3 tabs before executing the script, which invalidates the header() call

Link to comment
Share on other sites

Link to post
Share on other sites

<?php should the first line in your code. Anything before that (unless its captured in ob_start) will be sent to the client including the headers. It looks like you need to remove the spaces/tabs before <?php

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks for your help guys! I'm always having problems with tabs and spaces that float around.

Mah Build:  CPU: Intel i7-7700K COOLING: NZXT Kraken X52 GPU: Asus Strix GTX 1080 MOBO: Asus Strix Z270F RAM: 16GB GSKILL TridentZ RGB 3000 

CASE: In Win 303 STORAGE: Samsung 850 EVO 250GB, Seagate 1TB  SSHD PSU: EVGA Supernova G2 750W

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×