Solved

A new rule in header() from PHP 5.1.2

Posted on 2006-11-07
6
222 Views
Last Modified: 2013-12-13
Hi,

Question here:

1) I upgraded my php from 5.0.4 to 5.1.6

and

2) changed webhosting from W2000 to XPhome

(do not know what change is relevant here) ->

and started having problems with websites that contain session/header functions:

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\nautiluso\sindex.php:4) in C:\Inetpub\wwwroot\nautiluso\sindex.php on line 39

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Inetpub\wwwroot\nautiluso\sindex.php:4) in C:\Inetpub\wwwroot\nautiluso\sindex.php on line 40

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Inetpub\wwwroot\nautiluso\sindex.php:4) in C:\Inetpub\wwwroot\nautiluso\sindex.php on line 40

can anyone help, please?

jana

0
Comment
Question by:jbmd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 14

Expert Comment

by:Aamir Saeed
ID: 17901919
Write ob_start() at the very first line like
<?php ob_start();
   // code goes here
?>

write ob_ end_ flush() at the end of the code.
0
 
LVL 48

Expert Comment

by:hernst42
ID: 17905018
look at C:\Inetpub\wwwroot\nautiluso\sindex.php line 4 there might be an echo/print which makes the first output of the HTML-page. Make sure you call session_start() before any output is made
0
 
LVL 13

Accepted Solution

by:
rhickmott earned 250 total points
ID: 17913482
Check C:\Inetpub\wwwroot\nautiluso\sindex.php

make sure that there is no blank lines or output

=============
                                                  <- Blank Line
<?php
      session_start();
?>
=============


Will throw an error similar to this as the first line is blank so it will output a blank line and send HTML headers causing your script to fail.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 14

Expert Comment

by:CtrlAltDl
ID: 17941552
There is one or more characters in your php file that being sent at the beginning of your file.

If your using the Microsoft Expression Web Designer it has a known bug that adds a UTF-8 identifier to the file that causes a problem with php files.
0
 

Author Comment

by:jbmd
ID: 17943551
Actually - hernst42  was also close too.

My exact solution was this: I made sure, that there was no space and no line before session, and also in some pages I really had 2 headers per page (due to "include") - so I had to make sure there was only one header.

I can tell you this is really annoying that sometimes (quite often to my taste) webs are out of order after php update (remember register_globals? it was even worse).
I am just wondering if also other languages - like asp or so have this problem. For example I do not use perl very often but I know that the software in perl stays ok after many upgrades of perl.exe....

What do you think? I mean then I really have to approach my customers and explain them that their webs have errors just because of upgrade of php on the server. And sometimes they look at me ... as if I made it all up....  :-)
0
 
LVL 13

Expert Comment

by:rhickmott
ID: 17945431
The trick is to look at what's considered "Recommended Practice" for PHP scripts and follow it even if not doing so works.

You can be guaranteed if its recommended practice then at some point in the future your going to be forced to do it that way.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to implement server side field validation and display customized error messages to the client.
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.

617 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