473,414 Members | 1,823 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,414 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 2597
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.