Solved

A new rule in header() from PHP 5.1.2

Posted on 2006-11-07
6
204 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

759 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

19 Experts available now in Live!

Get 1:1 Help Now