473,434 Members | 1,503 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

Cannot modify header information - Headers already sent

Can anyone tell me what is wrong with this code?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if (isset($_COOKIE['referralcookie']['refid'])) {
  3. $url = $row_rsCookieReferral['cookiereferral_hoplink'];
  4.  
  5. header("Location: $url");
  6. }
  7. ?>
  8.  
[Please use CODE tags when posting source code. Thanks! --pbmods]

['referralcookie']['refid'] is a cookie I have set and
rsCookieReferral is a recordset I have on my page

My main issue is that I am getting this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/XXXMY_USERNAMEXXX/public_html/index.php:69) in /home/ezcogtem/public_html/index.php on line 73
Jun 19 '07 #1
5 2601
r035198x
13,262 8TB
Can anyone tell me what is wrong with this code?

<?php
if (isset($_COOKIE['referralcookie']['refid'])) {
$url = $row_rsCookieReferral['cookiereferral_hoplink'];

header("Location: $url");
}
?>




['referralcookie']['refid'] is a cookie I have set and
rsCookieReferral is a recordset I have on my page

My main issue is that I am getting this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/XXXMY_USERNAMEXXX/public_html/index.php:69) in /home/ezcogtem/public_html/index.php on line 73
Moved to PHP forum .
Jun 19 '07 #2
Ajm113
161 100+
Look around here:
http://www.php.net/manual/en/function.session-start.php

Their is a command to have it so you can add spaces after session start, but I forgot...
Jun 19 '07 #3
Purple
404 Expert 256MB
Hi half21back and welcome to TSDN

The error :

Expand|Select|Wrap|Line Numbers
  1. Warning: Cannot modify header information - headers already sent by (output started at /home/XXXMY_USERNAMEXXX/public_html/index.php:69) in /home/ezcogtem/public_html/index.php on line 73
is telling you your script has written output to the browser before you have issued your redirect - this is not allowed, thus the error. You can either find the write to the browser, this could be a php function ie echo, print() or could be as simple as whitespace in the html code around your php script. Take a look at line 73. If you cannot find the problem post the whole of index.php into this thread.

Regards Purple
Jun 19 '07 #4
Thank you guys,

Here is the updated code:

[PHP]
<?php
if (isset($_COOKIE['referralcookie']['refid'])) {
$url=$row_rsCookieReferral['cookiereferral_hoplink'];
header("Location: $url");
}
?>
[/PHP]

My page now works correctly. I believe it had to do with the white space as mentioned.

Regards,
Brad
Jun 19 '07 #5
pbmods
5,821 Expert 4TB
Changed thread title to actually describe the problem.
Jun 19 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Phyzlo | last post by:
Hello, I've recently started learning PHP and have a question. I tried running below script which can be found at http://se2.php.net/manual/sv/function.setcookie.php but I keep getting this...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
5
by: J Huntley Palmer | last post by:
I am getting this error: Cannot modify header information - headers already sent by when I issue a header ("Location: http://www.foobar.com"); How can I redirect the user to such a site...
19
by: lawrence k | last post by:
How can I find out where my script is outputting to the screen for the first time? My error logs are full of stuff like this: PHP Warning: session_start(): Cannot send session cache...
8
by: mcserret | last post by:
I know this is a recurring problem that has been addressed here before, but even after reading all that has gone before, I am still stumped. I have a form that is designed to send data to a PHP...
2
by: smartic | last post by:
I'm having problem with header redirection that is my code: <?php header("location:Redirecting.php"); exit; ?> //Then the HTML It give me an error
3
by: TechnoAtif | last post by:
Hi All. I have got problem with the header. If i run my php script in the local host it runs perfectly but if i do the same on net after loading it via ftp. it gives following error: The code...
2
by: pks83 | last post by:
Hello I am also facing this problem when i amtrying to send additional header information. Warning: Cannot modify header information - headers already sent by (output started at header.php:96)...
2
by: creative1 | last post by:
I get following error on page : Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\desiorb\411.php:9) in C:\xampp\htdocs\desiorb\411.php on line 21 when...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.