Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cookie problems

Status
Not open for further replies.

kehers

Programmer
Joined
Aug 31, 2005
Messages
56
Location
A2
i have a script dat goes this way
...
foreach($_GET as $k => $gv) {
$$k = stripslashes(trim($gv));
}

if(!$pg){
$pg = 1;
setcookie('query', $q);
}
...
however i got the error: Warning: Cannot modify header information - headers already sent by (output started at /var/ in /var/ on line 12

line 12 is this :setcookie('query', $q);

any idea wat could be wrong?
 
I'm picking that you have already output something to the page by the time you are attempting to setCookie(). You cannot output headers once you have delivered content... and this include whitespace (like a carriage return between ?> and <? tags for instance).

Walk back up the structure of your php and make sure that no whitespace or other output has been sent to the browser.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Status
Not open for further replies.

Similar threads

  • Locked
  • Question Question
Replies
21
Views
748
Replies
4
Views
309
  • Locked
  • Question Question
Replies
2
Views
219
  • Locked
  • Question Question
Replies
2
Views
193
Replies
2
Views
147

Part and Inventory Search

Sponsor

Back
Top