Page 1 of 1

Cannot modify header information. (Yes i have searched)

PostPosted: 15. February 2008 11:50
by SuperT
Hi,
I have recently gone from using appache and PHP5 as a stand alone to using xampp and i have been developing a basic CMS to learn PHP. My CMS login system was working fine on Appache stand alone but when i try to use it on xampp i get this when i try to log in:

Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\TXT CMS\admin\login.php:6) in D:\xampp\htdocs\TXT CMS\admin\login.php on line 29


Line 29 is where it sets the cookie and line 6 is the <?php tag and i have no trouble when i upload it to my web server.

Another strange thing is that when i was trying to fix it i tryed to log in and after several attempts my computer blue screened and said something about cookies before it shut down, This might be unrelated but i just thought i would add it in.

I have searched already for a solution and i have tryed recreating the lang.tmp file and there is no output before the cookie is set.

I hope someone can shed some light on my problem and Thankyou in advance for your time and help. :)

PostPosted: 15. February 2008 11:57
by Wiedmann
Line 29 is where it sets the cookie and line 6 is the <?php tag and i have no trouble when i upload it to my web server.

Then you have some (HTML?) output before "<?php".

PostPosted: 15. February 2008 22:45
by SuperT
This is all there is above the <?php tag.

<html>
<head>
<title>Admin</title>
</head>
<body>


There is a html file included just after the <?php tag but i tryed removing this and it didnt help.

PostPosted: 15. February 2008 23:09
by sari42
there must not be any output before a setcookie or "header(..." line.

But you can print those lines from the php part like so:
Code: Select all
<?php
header('....');
//maybe more header('....');
echo '<html>
<head>
<title>Admin</title>
</head>
<body>';
//rest of the php part....

(or you have to use ob_start....., both methods are explained in php.net)

PostPosted: 16. February 2008 01:08
by SuperT
Thanks, That worked. How come it worked on my web server and on my stand alone apache but not XAMPP?

Ps. This isnt related but you might know. In a url what does %22 replace?

PostPosted: 16. February 2008 10:26
by sari42
SuperT wrote:Thanks, That worked. How come it worked on my web server and on my stand alone apache but not XAMPP?
different setup.
Maybe "ob_start()...." in an autoprepend file or some such.
Ps. This isnt related but you might know. In a url what does %22 replace?
double quote: "