Solved

A new rule in header() from PHP 5.1.2

Posted on 2006-11-07
6
207 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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 count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now