get ip in 4.2+
Moderator: General Moderators
- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact:
get ip in 4.2+
i used to be able to use $REMOTE_ADDR, but what is the var in 4.2.1?
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact:
Code: Select all
echo $_SERVERї'REMOTE_ADDR'];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
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
Is it the localhost trying to access it? Maybe it has a problem with that.
do this:
do this:
Code: Select all
<pre>
<? print_r($_SERVER); ?>
</pre>- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact:
Code: Select all
<?php
print_r($_SERVERї'REMOTE_ADDR']);
?>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.
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact:
Code: Select all
<?php
echo "$HTTP_SERVER_VARS";
?>Array
of all the things it could echo out, it says "Array"?!?!?!
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
THAT IS A GOOD THING!
try doing this:
okay, with that simple misconseption out of the way try:
try doing this:
Code: Select all
<?
$array = array("1","2");
echo $array;
?>Code: Select all
<?=$HTTP_SERVER_VARSї'REMOTE_ADDR'];?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Instead of:
try
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
Code: Select all
print_r($_SERVERї'REMOTE_ADDR']);Code: Select all
echo '<pre>';
print_r($_SERVER);
echo '</pre>';Code: Select all
phpinfo();Mac
- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact:
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.
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.
Why can't you use $REMOTE_ADDR?
Have you tried
Have you tried
Code: Select all
<?php
print_r($HTTP_SERVER_VARS);
?>- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact:
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
Please read the rest of the post, and use common sense.Takuma wrote:Why can't you use $REMOTE_ADDR?
Have you tried
Code: Select all
<?php print_r($HTTP_SERVER_VARS); ?>
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?
