TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   gethostbyaddr (http://www.talkphp.com/general/3738-gethostbyaddr.html)

KingOfTheSouth 12-09-2008 02:04 AM

gethostbyaddr
 
I am getting a error for this new site I am making. here is the error. I have never seen this kind of error. So I do not know what to do.

Warning: gethostbyaddr() [function.gethostbyaddr]: Address is not a valid IPv4 or IPv6 address in /home1/clubbink/public_html/streetlords/signup.php on line 62

Code:

$host=gethostbyaddr("$REMOTE_ADDR");
What does this mean? And how can I fix this?

Wildhoney 12-09-2008 03:38 AM

php Code:
$szHost = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo 'Your host is: ' . $szHost;

The $REMOTE_ADDR method you're using is a really old way. I think that's attempting to use super-globals. I used them only once when freelancing at one particular place.

Orc 12-09-2008 05:33 AM

Quote:

Originally Posted by Wildhoney (Post 20353)
php Code:
$szHost = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo 'Your host is: ' . $szHost;

The $REMOTE_ADDR method you're using is a really old way. I think that's attempting to use super-globals. I used them only once when freelancing at one particular place.

I've never used it. :P, in fact, I've never seen it on the php documentation.

KingOfTheSouth 12-09-2008 10:48 PM

It is an apache server plugin all you will need to do is put a double slash in front of it. So it should look like this.
PHP Code:

//$host=gethostbyaddr("$REMOTE_ADDR"); 


Wildhoney 12-09-2008 11:09 PM

What will that do but comment it out?

KingOfTheSouth 12-09-2008 11:19 PM

Yes so it does not show the error or at top of html.php put error_reporting (0) This will shut off all errors

Wildhoney 12-09-2008 11:33 PM

I don't understand what you're attempting to do here. Double forward slash is a comment and therefore won't get executed at all, right?

php Code:
$host = 'Ignore the comment';
//$host=gethostbyaddr("$REMOTE_ADDR");
var_dump($host);

Quote:

Originally Posted by Above code
string(18) "Ignore the comment"


masfenix 12-09-2008 11:37 PM

Quote:

Originally Posted by KingOfTheSouth (Post 20384)
It is an apache server plugin all you will need to do is put a double slash in front of it. So it should look like this.
PHP Code:

//$host=gethostbyaddr("$REMOTE_ADDR"); 


I dont think its much of a "plugin" but just the interpreter ignoring the statements.

I think the OP wants his code to run but not give an error. If he didnt want the statement there he simply would've deleted it.

KingOfTheSouth 12-09-2008 11:41 PM

I do not know much about the plugin. It is a older script I do not know the creator. I could not tell you what it is doing there. But I did read somewhere that putting the double slash will block it out so that it will not show.

masfenix 12-09-2008 11:59 PM

I understand that, in PHP that means a comment. You use it to document your code.

PHP Code:

//declare variables
$name "fenix";
$num1 2;
$num2 2;

//print the name out
echo $name;

//calculate the numbers
echo $num1 $num2

You see how the comments are NOT being executed? Generally you would NOT comment code out. If you dont want it, delete it. If you want it make a library. Documenting code can sometimes have its advantages though.

For the sake of explaining it to this guy, I am gonna pretend PHP is compiled.

Okay, so when you run your script, your statements get converted into machine code. However when the compiler see's double slashes then it ignores that line.

Similarly you can comment a "block" by using /* and */. Anything inbetween is not seen by the compiler as runnable code so it skips it.

If your script depends on that statement, then the whole script will fail because now you are NOT executing the statement. Just to be on the safe side, you should uncomment it and use the suggestion given above.

I am assuming your new so you couldnt possibly debug where that variable is being used and how. So just uncomment it. If the script needs it then it will use it, if it dosnt well I think PHP has a garbage collector that will free the memory after.

Rainman 02-19-2013 05:26 AM

Welcome to mmoggg website to buy RS Gold, offer a lot, of course, Diablo 3 Gold and Cheap RS Gold, to be purchased at any time, at any time shipment, and Diablo 3 Gold Kaufen look forward to your visit!


All times are GMT. The time now is 05:29 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0