Cannot modify header information. (Yes i have searched)

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Cannot modify header information. (Yes i have searched)

Postby SuperT » 15. February 2008 11:50

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. :)
SuperT
 
Posts: 3
Joined: 15. February 2008 11:38

Postby Wiedmann » 15. February 2008 11:57

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".
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby SuperT » 15. February 2008 22:45

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.
SuperT
 
Posts: 3
Joined: 15. February 2008 11:38

Postby sari42 » 15. February 2008 23:09

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)
sari42
 
Posts: 800
Joined: 27. November 2005 18:28

Postby SuperT » 16. February 2008 01:08

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?
SuperT
 
Posts: 3
Joined: 15. February 2008 11:38

Postby sari42 » 16. February 2008 10:26

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: "
sari42
 
Posts: 800
Joined: 27. November 2005 18:28


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 164 guests