Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

same script different server:: header already sent error

Posted on 2011-05-02
9
Medium Priority
?
435 Views
Last Modified: 2012-06-21
A a test server I am using "Easy PHP Contact Form" On the live site it works, but on test server I get headers already sent errors:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/me/domain.com/contact.php:81) in /home/me/domain.com/contact.php on line 106

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/me/domain.com/contact.php:81) in /home/me/domain.com/contact.php on line 106

Warning: include(form-header.php) [function.include]: failed to open stream: No such file or directory in /home/me/domain.com/contact.php on line 321

Warning: include() [function.include]: Failed opening 'form-header.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/me/domain.com/contact.php on line 321

Open in new window


Any ideas why that is?
0
Comment
Question by:rhandalthor
  • 5
  • 2
  • 2
9 Comments
 
LVL 15

Accepted Solution

by:
ludofulop earned 1000 total points
ID: 35503099
hi, check your php.ini, and comment out output_buffering

output_buffering = On
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1000 total points
ID: 35503102
Your error message says they were sent at line 81.
0
 

Author Comment

by:rhandalthor
ID: 35503114
@DavidBaldwin. Same script works well at tiffinsolutions.com/contact.php and not at ts.imagewize.com/contact.php. What has changed? The server. But what has changed and how to fix this?
@ ludofulop Can this be done with a .htaccess? I do not have a dedicated server, just a DreamHost shared server.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1000 total points
ID: 35503150
The server and the error response has changed, simple as that.  If the original server is set to not report warnings as many are, maybe it's not working so well as you think.

Whenever you are having a problem with a PHP script, you should put this at the top of the script so it will report all errors so you can fix them.

error_reporting(E_ALL);
ini_set('display_errors','On');
0
 
LVL 15

Assisted Solution

by:ludofulop
ludofulop earned 1000 total points
ID: 35503172
setting it using .htaccess depends on your server configuration, try to put following line into .htaccess:
php_value output_buffering "On"

If it result #500 error, then you can't set it using .htaccess. Check your hosting, if you can use your own php.ini (some servers are allowing this).

If not, check your codes to prevent any output before session_start,
or put session_start to very top of your scripts (e.g. top of the first file loaded),
or use your own buffering  -  check out function ob_start, of_end_flush, etc.
0
 

Author Comment

by:rhandalthor
ID: 35503184
Done DaveBaldwin. Code is here: http://pastebin.ca/2052770 and live view - the same errors as far as I can see is here: http://www.ts.imagewize.com/contact.php. Perhaps Dreamhost reports more errors then previous server does. Need the script to work well on both ..
0
 

Author Comment

by:rhandalthor
ID: 35503208
Removed two errors. Looking into final one(s)
0
 

Author Comment

by:rhandalthor
ID: 35503214
0
 

Author Comment

by:rhandalthor
ID: 35503272
I did not mean to give myself points. Only the two contributors. Please adjust or allow me to award points again.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month20 days, 18 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question