Jump to content

Problem with domain to IP address translator!


CalumT

Recommended Posts

Hey there PHP freaks,

I'm trying to build a basic domain to IP address translator, I have this code:


[code]<?php
$site=addslashes(strip_tags($_POST['site']));
$ipaddress = gethostbyname $site;
echo "The IP address of $site is $ipaddress";
?>[/code]

But It returns this error when I submit the form I created:

[i]Parse error: parse error, unexpected T_VARIABLE in /home/calumla/public_html/processip.php on line 97[/i]

Line 97, with my HTML is this:

[code]$ipaddress = gethostbyname $site;[/code]

All help is appriciated, thanks!

~Calum
Link to comment
Share on other sites

[!--quoteo(post=369548:date=Apr 28 2006, 07:16 AM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Apr 28 2006, 07:16 AM) [snapback]369548[/snapback][/div][div class=\'quotemain\'][!--quotec--]
gethostbyname requires enclosed ().

so it should be

[code]$ipaddress = gethostbyname ('$site');[/code]

Ray
[/quote]

Thanks Ray, but there's still an error, If I put in Microsoft.com, I get this

[i] The IP address of microsoft.com is $site[/i]

Any ideas?
Link to comment
Share on other sites

[!--quoteo(post=369553:date=Apr 28 2006, 10:28 PM:name=-Calum-)--][div class=\'quotetop\']QUOTE(-Calum- @ Apr 28 2006, 10:28 PM) [snapback]369553[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Thanks Ray, but there's still an error, If I put in Microsoft.com, I get this

[i] The IP address of microsoft.com is $site[/i]

Any ideas?
[/quote]

Hi,
Remove the quotes

[code]$ipaddress = gethostbyname($site);[/code]

HTH
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.