Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 12th, 2008, 8:06 AM   #1
stu7398
Newbie
 
Join Date: Jan 2008
Posts: 3
Rep Power: 0 stu7398 is on a distinguished road
Warning: Cannot modify header information - headers already sent by (output started at

I am looking for my contact form when submitting, to redirect to a 'thank you' page, however I receive the following error.
Warning: Cannot modify header information - headers already sent by (output started at

I am new to php programming; clear instructions or language is appreciated.

Thanks.
stu7398 is offline   Reply With Quote
Old Jan 12th, 2008, 8:37 AM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Re: Warning: Cannot modify header information - headers already sent by (output started at

The function, "header", can not be called if you've already made the script output text to the client.

For example:

PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. echo 'Hello World!'
  4. header('Content-type: text/plain');
  5.  
  6. ?>

Will throw an error, because it tried to modify the header after all of the headers were sent to the client.

PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. header('Content-type: text/plain');
  4. echo 'Hello World!'
  5.  
  6. ?>

This will work. Because the header is modified, and then output is sent.
Sane is offline   Reply With Quote
Old Jan 12th, 2008, 11:30 AM   #3
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 747
Rep Power: 3 Jimbo is on a distinguished road
Re: Warning: Cannot modify header information - headers already sent by (output started at

Also of note, the PHP code must be the first thing in the file. The following will not work:
<!DOCTYPE blah blah blah>
<?php
    header('foo');
?>
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote
Old Jan 14th, 2008, 12:14 AM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Re: Warning: Cannot modify header information - headers already sent by (output started at

If you still want to supress the error, you can do so by calling the error_reporting function. Or, if you want to do it for all files, edit the php.ini file - check the line beginning with "error_reporting = ".

If this is your production server, turning display_errors off and log_errors on in your php.ini file is recommended, so if there are any errors, your users don't see them but you do. If it's your development server, I'd recommend the opposite - set error_reporting to E_ALL, display_errors to On and log_errors to Off.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 18th, 2008, 8:06 AM   #5
FERDIKUCUK
Php Coder
 
Join Date: Feb 2008
Posts: 5
Rep Power: 0 FERDIKUCUK is on a distinguished road
Send a message via MSN to FERDIKUCUK
Arrow Re: Warning: Cannot modify header information - headers already sent by (output started at

<?php 
ob_start();session_start();
echo "ferdi kucuk";
header("location : url");
?>

ob_start();

FERDIKUCUK is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
solving warning messages, in a program kalulu C 4 Nov 25th, 2005 8:41 PM
Installing IPB 2.03 bh4575 Other Web Development Languages 0 Apr 23rd, 2005 2:36 AM
Warning: The dependency 'mydll' cannot be Warning:The dependency A cannot be copied.. sarav C# 1 Apr 12th, 2005 7:18 PM
TCP Header for Echo Communication AusTex C++ 0 Feb 27th, 2005 3:57 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:43 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC