cannot modify header information error (randomblock)

kmaisch

Joined: 2004-04-26
Posts: 79
Posted: Fri, 2005-04-15 08:14

Please see my main page at http://www.kmaisch.com

Since upgrading from 1.4.4 to 1.5 my randomblock gives the following error:

Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/kmaisch.com/httpdocs/index.php:8) in /home/httpd/vhosts/kmaisch.com/httpdocs/gallery/lib/lang.php on line 356

I have deleted the randomblock cache files.

Any ideas?
Kim

 
sethp

Joined: 2002-11-05
Posts: 16
Posted: Sat, 2005-04-16 20:53

I have the exact same situation on the custom front page of my site where I'm displaying the random photo. The random photo is displayed, but with the "cannot modify header information" warning.

I also just upgraded today from 1.4.4 to v1.5-RC3. Is this a know problem?

 
kmaisch

Joined: 2004-04-26
Posts: 79
Posted: Sun, 2005-04-17 06:15

ah, so I'm not the only one at least.

Anyone have a fix for this? The randomblock works fine on its own... it just spits out that error when it is inserted onto another php page.

sethp - let me know if you find a solution!

Cheers,
Kim

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Sun, 2005-04-17 06:20

Make sure that you're including the random block via HTTP, not via file.

Read the tutorial at the top of this forum.

 
kmaisch

Joined: 2004-04-26
Posts: 79
Posted: Sun, 2005-04-17 06:54

in my index.php page on my main website, i have inserted:

<?php
	  include('gallery/block-random.php');
?>

That should work, shouldnt it?

Kim

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Sun, 2005-04-17 07:03

No.

You need to use http://yourhost/gallery/block-random.php

 
kmaisch

Joined: 2004-04-26
Posts: 79
Posted: Sun, 2005-04-17 10:54

tried that but i get URL file-access errors:

Warning: main(): URL file-access is disabled in the server configuration in /home/httpd/vhosts/kmaisch.com/httpdocs/index.php on line 79
 
sethp

Joined: 2002-11-05
Posts: 16
Posted: Sun, 2005-04-17 17:45

I changed my include() statement to point to the URL as signe suggested, and that removed the headers warning for me. Thanks, signe.

Something must have changed with block-random.php or gallery related to this, because the include("/serverpath/gallery/block-random.php"); call use to work for me.

Good luck, kmaisch.

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Mon, 2005-04-18 03:15

You could probably also open up that block-random.php file and locate any place that outputs header stuff like <html> etc and comment out or delete it. I think that the changes were made so that the file could be its own stand-a-lone page and actually validate.

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Mon, 2005-04-18 03:19

That's not the issue. The problem is that the random block is trying to send header information and it has already been sent by the page that's including it.

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Mon, 2005-04-18 03:21

Right, and if you remove all the code that CAN send header information wont that fix the problem? If there isn't anything sending header info, how can you get the error? I would save the file as a new name though so upgrades and stuff don't fork you over.

 
kmaisch

Joined: 2004-04-26
Posts: 79
Posted: Mon, 2005-04-18 03:22
signe wrote:
That's not the issue. The problem is that the random block is trying to send header information and it has already been sent by the page that's including it.

So might fryfrog's suggestion work? I'll give it a go...

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Mon, 2005-04-18 03:26

I think it would, but obviously signe doesn't... and on the scale of Gallery devs... I am at the bottom and he is not... so I would not wager on me! But I would still try it because I am very daring! And really its just code :)

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Mon, 2005-04-18 03:31

No... the issue isn't with the block, it's with the page it's included in.

Since the page has already sent text (the body) and the block is in the middle of the body, the block can't send headers, hence the error.

The *only* way that the random block works successfully is with http includes.

 
kmaisch

Joined: 2004-04-26
Posts: 79
Posted: Mon, 2005-04-18 03:40

Well, it did work fryfrog, however I had to delete something from lib/lang.php which probably really should stay in.

I went to line 356 and deleted:

	if (! isset($GALLERY_EMBEDDED_INSIDE) || $sendHeader == false) {
		header('Content-Type: text/html; charset=' . $gallery->charset);
	}

It also had a bit before saying **this check is to ensure header information is not sent if it is already sent** - but I guess this check doesnt work?

Also - because my server does not allow URL file-access with PHP Safe Mode I had to use:

<?php
     include('gallery/block-random.php');
?>

Signe - how can I get it working using http includes? Is this Sever Side Includes stuff (shtml).

What else would that lang.php stuff that I removed affect? I've given my gallery a good going over and everything else seems to work still...

Kim