ChrisMartino Posted November 26, 2009 Share Posted November 26, 2009 "Warning: Cannot modify header information - headers already sent by (output started at /home/christop/public_html/websites/file/register.php:9) in /home/christop/public_html/websites/file/register.php on line 97" this is the script: http://pastebin.com/m713e3ac Link to comment https://forums.phpfreaks.com/topic/182972-how-do-i-solve-this-error-warning-cannot-modify-header-information/ Share on other sites More sharing options...
oni-kun Posted November 26, 2009 Share Posted November 26, 2009 You must add ob_start at the top of your PHP script (above any whitespace) to rectify the problem. It starts the output buffer. <?php ob_start(); //start the output buffer, at the top! ?> [html code..] <?php header('Location:...');// Works now ?> EDIT: Place it ABOVE any of your HTML code, ob_start at top, close the tag and then you can output HTML. Link to comment https://forums.phpfreaks.com/topic/182972-how-do-i-solve-this-error-warning-cannot-modify-header-information/#findComment-965752 Share on other sites More sharing options...
keldorn Posted November 26, 2009 Share Posted November 26, 2009 I dont feel like repeating myself, read this. I already explained this and also gave a good example of ob_start() http://www.phpfreaks.com/forums/index.php/topic,277876.0.html Link to comment https://forums.phpfreaks.com/topic/182972-how-do-i-solve-this-error-warning-cannot-modify-header-information/#findComment-965764 Share on other sites More sharing options...
ChrisMartino Posted November 26, 2009 Author Share Posted November 26, 2009 that worked, Thanks!, But now i get this "Register Register your *Free account at FreeFile! Warning: Cannot modify header information - headers already sent by (output started at /home/christop/public_html/websites/file/register.php:9) in /home/christop/public_html/websites/file/register.php on line 110" http://pastebin.com/m6f6294d6 Link to comment https://forums.phpfreaks.com/topic/182972-how-do-i-solve-this-error-warning-cannot-modify-header-information/#findComment-965765 Share on other sites More sharing options...
oni-kun Posted November 26, 2009 Share Posted November 26, 2009 that worked, Thanks!, But now i get this "Register Register your *Free account at FreeFile! Warning: Cannot modify header information - headers already sent by (output started at /home/christop/public_html/websites/file/register.php:9) in /home/christop/public_html/websites/file/register.php on line 110" http://pastebin.com/m6f6294d6 Is register.php the file you put ob_start() in? If it's another php file than I believe you must do the same for it. Headers are meant to be sent before content, so you have to use this 'bandage' to let it work that way. Sometimes they completely fail and you must find a different method, but this one doesn't seem too hard. Link to comment https://forums.phpfreaks.com/topic/182972-how-do-i-solve-this-error-warning-cannot-modify-header-information/#findComment-965768 Share on other sites More sharing options...
keldorn Posted November 26, 2009 Share Posted November 26, 2009 You should use Switch statments, what you doing is nightmare to manage.. The elese if statments, try this. Why no just put your "Business logic" in the top of the page? Then assign the variables back to the page with arrays, (You can see this example of what I mean by) Here is a switch statment, // register.php?action=register Switch($_GET['action']){ case 'register': // stuff break; // Completely exits the switch statement case 'thanks': // stuff break; default: // nothing break; } Link to comment https://forums.phpfreaks.com/topic/182972-how-do-i-solve-this-error-warning-cannot-modify-header-information/#findComment-965770 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.