Jump to content

How do i solve this error? (Warning: Cannot modify header information)


Recommended Posts

"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

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.

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

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.

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;
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.