TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-09-2008, 02:04 AM   #1 (permalink)
The Acquainted
 
KingOfTheSouth's Avatar
 
Join Date: Oct 2008
Location: Cincinnati
Posts: 151
Thanks: 14
KingOfTheSouth is on a distinguished road
Default 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?
KingOfTheSouth is offline  
Reply With Quote
Old 12-09-2008, 03:38 AM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

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.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 12-09-2008, 05:33 AM   #3 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
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.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 12-09-2008, 10:48 PM   #4 (permalink)
The Acquainted
 
KingOfTheSouth's Avatar
 
Join Date: Oct 2008
Location: Cincinnati
Posts: 151
Thanks: 14
KingOfTheSouth is on a distinguished road
Default

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"); 
KingOfTheSouth is offline  
Reply With Quote
Old 12-09-2008, 11:09 PM   #5 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

What will that do but comment it out?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 12-09-2008, 11:19 PM   #6 (permalink)
The Acquainted
 
KingOfTheSouth's Avatar
 
Join Date: Oct 2008
Location: Cincinnati
Posts: 151
Thanks: 14
KingOfTheSouth is on a distinguished road
Default

Yes so it does not show the error or at top of html.php put error_reporting (0) This will shut off all errors
KingOfTheSouth is offline  
Reply With Quote
Old 12-09-2008, 11:33 PM   #7 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

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"
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 12-09-2008, 11:37 PM   #8 (permalink)
The Contributor
 
Join Date: Mar 2008
Posts: 31
Thanks: 1
masfenix is on a distinguished road
Default

Quote:
Originally Posted by KingOfTheSouth View Post
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.
masfenix is offline  
Reply With Quote
Old 12-09-2008, 11:41 PM   #9 (permalink)
The Acquainted
 
KingOfTheSouth's Avatar
 
Join Date: Oct 2008
Location: Cincinnati
Posts: 151
Thanks: 14
KingOfTheSouth is on a distinguished road
Default

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.
KingOfTheSouth is offline  
Reply With Quote
Old 12-09-2008, 11:59 PM   #10 (permalink)
The Contributor
 
Join Date: Mar 2008
Posts: 31
Thanks: 1
masfenix is on a distinguished road
Default

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.
masfenix is offline  
Reply With Quote
Old 02-19-2013, 05:26 AM   #11 (permalink)
The Wanderer
 
Join Date: Feb 2013
Posts: 17
Thanks: 0
Rainman is on a distinguished road
Default

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!
Rainman is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 01:42 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design