Jump to content


Photo

can you capture server IP address?


  • Please log in to reply
5 replies to this topic

#1 bcamp1973

bcamp1973
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 16 May 2006 - 09:03 PM

I run a local dev environment and i want to put a <base href=""> tag in my dev sites so my colleagues can look at things as i'm working on them. So, say my ip is 123.45.67.01 and my project is in the "proj01" directory. I want to use PHP to build the following <base> tag...


<base href="http://123.45.67.01/proj01/" />


obviously $_SERVER['HTTP_HOST'] doesn't work...is there a field in the server array for the IP address (and i don't mean 127.0.0.1) or any other way to capture that information?

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 16 May 2006 - 11:06 PM

$_SERVER['SERVER_ADDR']
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 bcamp1973

bcamp1973
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 16 May 2006 - 11:08 PM

[!--quoteo(post=374471:date=May 16 2006, 07:06 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 16 2006, 07:06 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
$_SERVER['SERVER_ADDR']
[/quote]

unfortunately that gives me "127.0.0.1", not the IP my colleagues need to access my macine :(

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 16 May 2006 - 11:13 PM

really? hmm. well i tested it on my host and it seemed to work just fine? i'm not an expert so i couldn't tell you why it doesn't work. sorry...
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 exeterdad

exeterdad
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 17 May 2006 - 01:48 AM

Either one should work!?

Are you accessing the script with [a href=\"http://localhost\" target=\"_blank\"]http://localhost[/a] or 127.0.0.1 (loopback) or [a href=\"http://yourIPaddresshere\" target=\"_blank\"]http://yourIPaddresshere[/a]?

All of them make a difference. Obviously your colleagues will have to use [a href=\"http://yourIPaddresshere\" target=\"_blank\"]http://yourIPaddresshere[/a] since they are outside of your network.

Try it, I bet it works [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

Easy way to test which one works for you is to run phpinfo() with all three methods mentioned above. You will see the difference.

#6 bcamp1973

bcamp1973
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 17 May 2006 - 02:53 AM

[!--quoteo(post=374517:date=May 16 2006, 09:48 PM:name=exeterdad)--][div class=\'quotetop\']QUOTE(exeterdad @ May 16 2006, 09:48 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Either one should work!?
[/quote]

ok, i'm an idiot. You're both right, it does work. The only failure here was my typing skills. I overlooked a typo. THanks to you both!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users