?
Solved

A new rule in header() from PHP 5.1.2

Posted on 2006-11-07
6
Medium Priority
?
227 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 1000 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
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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

719 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