Solved

A new rule in header() from PHP 5.1.2

Posted on 2006-11-07
6
209 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
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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

770 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