Page 1 of 2
get ip in 4.2+
Posted: Thu Sep 12, 2002 8:18 pm
by Sevengraff
i used to be able to use $REMOTE_ADDR, but what is the var in 4.2.1?
Posted: Thu Sep 12, 2002 8:40 pm
by hob_goblin
either:
$_SERVER['REMOTE_ADDR'];
or
getenv('REMOTE_ADDR');
Posted: Thu Sep 12, 2002 8:47 pm
by Sevengraff
Code: Select all
echo $_SERVERї'REMOTE_ADDR'];
gets me the error:
Notice: Undefined index: REMOTE_ADDR in
E:\web\sevengraff media\sys\tag\make_tag.php on line
22
and getenv('REMOTE_ADDR') did nothing. no error or anything, just nothing
Posted: Thu Sep 12, 2002 9:02 pm
by hob_goblin
Is it the localhost trying to access it? Maybe it has a problem with that.
do this:
Code: Select all
<pre>
<? print_r($_SERVER); ?>
</pre>
Posted: Thu Sep 12, 2002 9:12 pm
by phice
I love the new $_VARIABLES

Posted: Thu Sep 12, 2002 9:12 pm
by phice
phice wrote:I love the new $_VARIABLES

"It makes life so much easier..."
Posted: Thu Sep 12, 2002 9:28 pm
by Sevengraff
Code: Select all
<?php
print_r($_SERVERї'REMOTE_ADDR']);
?>
same error as before, undefined index.
im also having problems passing variables using the POST method. i use
if (isset($_REQUEST['name'])) { $name = $_REQUEST['name']; }
to make it easier to use, when i try to use $name or $_REQUEST['name'], it says that they are undefined.
Posted: Thu Sep 12, 2002 9:30 pm
by hob_goblin
try
$HTTP_SERVER_VARS ?
Posted: Thu Sep 12, 2002 9:44 pm
by Sevengraff
Code: Select all
<?php
echo "$HTTP_SERVER_VARS";
?>
returns
Array
of all the things it could echo out, it says "Array"?!?!?!
Posted: Thu Sep 12, 2002 10:07 pm
by hob_goblin
THAT IS A GOOD THING!
try doing this:
Code: Select all
<?
$array = array("1","2");
echo $array;
?>
okay, with that simple misconseption out of the way try:
Code: Select all
<?=$HTTP_SERVER_VARSї'REMOTE_ADDR'];?>
Posted: Fri Sep 13, 2002 2:05 am
by twigletmac
Instead of:
Code: Select all
print_r($_SERVERї'REMOTE_ADDR']);
try
Code: Select all
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
as Hobgoblin did at one point say. This will allow you to see exactly what is in the $_SERVER array (if anything). Alternatively, you could try
which will show all variables that are set as well as the version number for PHP and all it's configuration settings. If you've got PHP 4.2.1 there's no reason why $HTTP_SERVER_VARS would work but not $_SERVER.
Mac
Posted: Fri Sep 13, 2002 1:50 pm
by Sevengraff
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
i got:
Array
(
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[SCRIPT_FILENAME] => E:\\program files\\PHP\\php.exe
[PATH_TRANSLATED] => E:\\program files\\DzSoft\\PHP Editor\\php5.tmp
[SCRIPT_NAME] => /php5.tmp
[REQUEST_URI] => /php5.tmp
[SYSTEMROOT] => C:\\WINNT
[WINDIR] => C:\\WINNT
[REDIRECT_STATUS] => 0
[PHP_SELF] => /php5.tmp
[argv] => Array
(
)
[argc] => 0
)
none of witch seemed to be an IP address.
Posted: Fri Sep 13, 2002 4:17 pm
by Takuma
Why can't you use $REMOTE_ADDR?
Have you tried
Code: Select all
<?php
print_r($HTTP_SERVER_VARS);
?>
Posted: Sat Sep 14, 2002 12:19 pm
by Sevengraff
print_r($HTTP_SERVER_VARS); did the same as the other one i tried.
also, it wont reconize vars that i pass with a forum. i used the POST method, but on the page that is suppost to get them, it says they are undefined.
Posted: Sat Sep 14, 2002 12:25 pm
by hob_goblin
Takuma wrote:Why can't you use $REMOTE_ADDR?
Have you tried
Code: Select all
<?php
print_r($HTTP_SERVER_VARS);
?>
Please read the rest of the post, and use common sense.
Sevengraff: Can you get the REMOTE_ADDR on other pages? Did you try phpinfo? Would it be too much of a hassle to reinstall php?