Jump to content

Header Warning message after upgrading PHP


coupe-r

Recommended Posts

Hi All,

 

I just formatted my HD and had a WAMP setup.  I have not installed each component separately (newest versions).

 

When I type in a text box and press the submit button, I get:

 

Warning: Cannot modify header information - headers already sent by (output started at D:\Web\Apache\htdocs\projects\tms_new\functions\functions.js:304) in D:\Web\Apache\htdocs\projects\tms_new\apps\index.php on line 167

 

Line 304 in the functions.js file is:  </script>

 

Line 167 in index.php is:

header('Location: index.php?lastname='.stripslashes($lastname));

 

It says I am sending header information before line 167, but there isn't any.  The .JS file only has JS code.

 

Can someone give me any suggestions?

 

Thanks everyone!!

Hello.  I did read that, and putting ob_start(); at the very top of my script solves the issue, but is this truly the right way?

 

I just don't want a quick fix, I'd rather learn the proper way.

 

I know you deal with this a lot, so I apologize for how this came off.

That error has likely been there for a long time, but error reporting was off. Now that you've reinstalled php, error reporting is on (as it should always be while developing) and the error is being displayed. Anyhow, read the thread btherl pointed out. <---- Edit: I see you've done that . . .

The right way is to change the logic so no headers would need to be sent after output has started. Hint: since javascript is a client-side language, it has to be sent to the browser.

Thank you.

 

So I did this and everything looks OK.  So basically, never user header() when you want to take the user somewhere else.  Correct?  Thanks again man.

 

echo '<meta http-equiv="refresh" content="0;url=index.php?lastname='.stripslashes($lastname).'">';
//header('Location: index.php?lastname='.stripslashes($lastname));

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.