tags:

views:

127

answers:

2

I am receiving this warning in a page while I try starting the session.

<?php
    session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Video</title>
</head>

-this is the part of the code. There are no characters (not even space) before the first line. This page is reached after logging in from another page, through redirection. Any help? (PHP version is 5.2)

+1  A: 

i don't know where but your script sent some output before, it's the warning message complete ? it's usually tell also where the output started.

If are unsure about where the output started you can try to use the output buffering libs. Put an ob_start(); at the very beginning of you script and $bad_output = ob_get_clean(); just before session_start(); now in the $bad_output you have the output that disturb your script.

Cesar
this won't help against BOM
Col. Shrapnel
i didn't know, never had BOM issues :)
Cesar
I tried this but it doesn't show anything, i.e, string(0) "".The code is run in xampp and php 5.2. Any possible compatibilty issues or something?And the rest of the error is "output started at line 1"..but apparently there's nothing there.
shyam
i checked wikipedia about "Unwanted BOM", as Syntax Error said, because i was curious... it's looks like your problem, you can find there also some advices about how to resolve :)
Cesar
+2  A: 

It's not unheard of for a BOM (Byte order mark) to lurk at the beginning of the file and screw this up, depending on the encoding (UTF-16 or also possible for UTF-8). Redirection wouldn't have anything to do with it.

See http://en.wikipedia.org/wiki/Byte_order_mark and scroll down to "Unwanted BOM"

Solution: view the page as Latin-1 and look for  at the beginning. I've had this happen to me before.

Syntax Error