We help IT Professionals succeed at work.

$_SERVER["HTTP_CLIENT_IP"] causes error in FastCGI mode

Kyanzes
Kyanzes asked
on
So, I have a piece of code that worked perfectly up until now, that is, under ISAPI mode.

Now I have installed PHP in FastCGI and the following code no longer works:

$cip = $_SERVER["HTTP_CLIENT_IP"] ;

The PHP version is 5.2.9-2 for both installations (the old ISAPI and the current FastCGI).

The error thrown:

Client found response content type of '', but expected 'text/xml'. The request failed with the error message: -- PHP Warning: Call-time pass-by-reference has been deprecated in C:\inetpub\wwwroot\TEST\WS\wsdatahandler.php on line 781 PHP Warning: Call-time pass-by-reference has been deprecated in C:\inetpub\wwwroot\TEST\WS\wsdatahandler.php on line 781 PHP Warning: Call-time pass-by-reference has been deprecated in C:\inetpub\wwwroot\TEST\WS\wsdatahandler.php on line 894 PHP Warning: Call-time pass-by-reference has been deprecated in C:\inetpub\wwwroot\TEST\WS\wsdatahandler.php on line 897 PHP Warning: Call-time pass-by-reference has been deprecated in C:\inetpub\wwwroot\TEST\WS\wsdatahandler.php on line 897 PHP Notice: Undefined index: HTTP_CLIENT_IP in C:\inetpub\wwwroot\TEST\WS\wshandler.php on line 225 PHP Notice: Undefined index: HTTP_X_FORWARDED_FOR in C:\inetpub\wwwroot\TEST\WS\wshandler.php on line 225 --.

PHP version is unchanged, IIS is unchanged.

What could be the root of the problem???

Comment
Watch Question

It's an older constant which is now dead. Try

$cip = $_SERVER["REMOTE_ADDR"] ;

instead

Avinash ZalaWeb Expert

Commented:
user  $_SERVER['REMOTE_ADDR']

Hope this helps,
Addy
I should also point out that the bulk of the errors listed have nothing to do with the $_SERVER["HTTP_CLIENT_IP"]  error. They refer to a different problem. You used to be able to do this

myFunction( & $aVariable );

forcing a "call by reference" at runtime. This has also been outlawed in newer versions of PHP and you must declare the call-by-reference in the function definition instead like so

function myFunction( & $param ) {
....code....
}


myFunction( $aVariable );

Author

Commented:
Thanks.