If you are not registered or logged in, you may still use these forums but with limited features. Show recent topics
  [Search] Search   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [FAQ]  FAQ 
[Register] Register / 
[Login] Login 
PHP Error  XML
Forum Index » Support Forum
Author Message
Anonymous



Hi,

I get this error at www.britishgp-sc.co.uk
Anyone help?
Cheers.

Warning: Cannot modify header information - headers already sent by (output started at /home/britgpsc/public_html/index.htm:3) in /home/britgpsc/public_html/poll/poll_cookie.php on line 21
Carbonize
Master
[Avatar]

Joined: 12/06/2003 19:26:08
Messages: 4292
Location: Bristol, UK
Offline

Self explanatory. On line 21 of poll_cookie.php you have some white space. I assume that the code ends at line 20 or 21. The end is ?>. Open the file and see if you can place the cursor beyond the ?> and if you can delete the space until the cursor is just after the ?>.

Carbonize
I am not the maker of the Advanced Guestbook

get Lazarus
[Email] [WWW] [Yahoo!] aim icon [MSN] [ICQ]
Anonymous



Carbonize wrote:Self explanatory. On line 21 of poll_cookie.php you have some white space. I assume that the code ends at line 20 or 21. The end is ?>. Open the file and see if you can place the cursor beyond the ?> and if you can delete the space until the cursor is just after the ?>.



Thanks for replying so quickly, my code is as below with no spaces and it still does it

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<?php
// Important! You have to include it before your html code
include_once "/home/britgpsc/public_html/poll/poll_cookie.php";
?>
<html><!-- InstanceBegin template="/Templates/index.dwt" codeOutsideHTMLIsLocked="false" -->
Carbonize
Master
[Avatar]

Joined: 12/06/2003 19:26:08
Messages: 4292
Location: Bristol, UK
Offline

No as i said the problem is in the file called poll_cookie.php

Carbonize
I am not the maker of the Advanced Guestbook

get Lazarus
[Email] [WWW] [Yahoo!] aim icon [MSN] [ICQ]
Anonymous



Carbonize wrote:No as i said the problem is in the file called poll_cookie.php


Cheers, as below, no white space? help!

<?php
/**
* ----------------------------------------------
* this code is optional
* Important! You have to include it
* before your html code
* ----------------------------------------------
*/

$cookie_expire = 96; // hours

$action = (isset($HTTP_GET_VARS['action'])) ? $HTTP_GET_VARS['action'] : '';
$action = (isset($HTTP_POST_VARS['action'])) ? $HTTP_POST_VARS['action'] : $action;
$poll_ident = (isset($HTTP_GET_VARS['poll_ident'])) ? $HTTP_GET_VARS['poll_ident'] : '';
$poll_ident = (isset($HTTP_POST_VARS['poll_ident'])) ? $HTTP_POST_VARS['poll_ident'] : $poll_ident;

if ($action=="vote" && (isset($HTTP_POST_VARS['option_id']) || isset($HTTP_GET_VARS['option_id']))) {
$cookie_name = "AdvancedPoll".$poll_ident;
if (!isset($HTTP_COOKIE_VARS[$cookie_name])) {
$endtime = time()+3600*$cookie_expire;
setcookie($cookie_name, "1", $endtime);
}
}

?>
Anonymous



I've cleaned it up and it still does it (

<?php
/**
* ----------------------------------------------
* this code is optional
* Important! You have to include it
* before your html code
* ----------------------------------------------
*/

$cookie_expire = 96; // hours

$action = (isset($HTTP_GET_VARS['action'])) ? $HTTP_GET_VARS['action'] : '';
$action = (isset($HTTP_POST_VARS['action'])) ? $HTTP_POST_VARS['action'] : $action;
$poll_ident = (isset($HTTP_GET_VARS['poll_ident'])) ? $HTTP_GET_VARS['poll_ident'] : '';
$poll_ident = (isset($HTTP_POST_VARS['poll_ident'])) ? $HTTP_POST_VARS['poll_ident'] : $poll_ident;

if ($action=="vote" && (isset($HTTP_POST_VARS['option_id']) || isset($HTTP_GET_VARS['option_id']))) {
$cookie_name = "AdvancedPoll".$poll_ident;
if (!isset($HTTP_COOKIE_VARS[$cookie_name])) {
$endtime = time()+3600*$cookie_expire;
setcookie($cookie_name, "1", $endtime);
}
}
?>
amber222
Graduate

Joined: 07/05/2004 21:13:07
Messages: 586
Offline

It looks like the spaces removed were on lines inside the functions(?) Check for blank lines, not spaces, especially make sure there are no blank lines after the ?> at the end. Here's how my code looks:



Here are some posts explaining:

"Warning: Cannot modify header information - headers already sent by...":
http://proxy2.de/forum/viewtopic.php?t=3200&highlight=cannot+modify+headers
http://proxy2.de/forum/viewtopic.php?t=3093&highlight=cannot+modify+header

The reason they end with the phrase "cannot+modify+header" is because they were located by using the search button at the top of this forum and searching for cannot AND modify AND header. Just so you know you can find info that way.
Anonymous



Cheers,
As an aside what should my index page be like out of the three examples below;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<?php
// Important! You have to include it before your html code
include_once "/home/britgpsc/public_html/poll/poll_cookie.php";
?>
<html>
<head>
<!-- TemplateInfo codeOutsideHTMLIsLocked="false" -->

OR

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<?php
// Important! You have to include it before your html code
include_once "/home/britgpsc/public_html/poll/poll_cookie.php";
?>
<head>
<!-- TemplateInfo codeOutsideHTMLIsLocked="false" -->

OR

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<?php
// Important! You have to include it before your html code
include_once "/home/britgpsc/public_html/poll/poll_cookie.php";
?>
<!-- TemplateInfo codeOutsideHTMLIsLocked="false" -->

Thanks,
Ricky.
Anonymous



Cookie code first, before any html, and poll code wherever you want it to appear...example:
Anonymous



Wohoo! that's fixed the cookie error!
Cheers.
Code appears right at the top now.
Many thanks,
Ricky.


Anonymous wrote:Cookie code first, before any html, and poll code wherever you want it to appear...example:
 
Forum Index » Support Forum
Go to:   
Based on the open source JForum