Jump to content

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

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.