0

Hi, everybody:

I have written an include file in my php file "main.php", with and include "ip.php", which is:

<?php
function getRealIpAddr()
{
if (!empty($_SERVER)){ //check ip from share internet
$ip=$_SERVER;
}
elseif (!empty($_SERVER)){ //to check ip is pass from proxy
$ip=$_SERVER;
}
else{
$ip=$_SERVER;
}
return $ip;
}
?>

My "main.php" is:

<?php
include("ip.php");
...
setcookie("US", $one.$two, $expire);
...
>

When I execute it, the "setcookie" gives me the error: "Warning: Cannot modify header information - headers already sent by (output started at .../ip.php:21) in .../main.php on line 402"
The header is supposed to be set in line 21, but line 21 does not exist!!!
Any help?

Thank you,

Xagutxu

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by xagutxu
0

Thank you, codewall. It has been very helpful for me.
The fact is that I had a blank line in the end of the library-function. So, it was printing a line, which is incompatible with the posterior header-settings. It is a little detail, but very important conceptually.

Thank you again,

Xagutxu

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.