Jump to content


Photo

Problem with domain to IP address translator!


  • Please log in to reply
3 replies to this topic

#1 CalumT

CalumT
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 April 2006 - 12:08 PM

Hey there PHP freaks,

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


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

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

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

Line 97, with my HTML is this:

$ipaddress = gethostbyname $site;

All help is appriciated, thanks!

~Calum

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 28 April 2006 - 12:16 PM

gethostbyname requires enclosed ().

so it should be

$ipaddress = gethostbyname ('$site');

Ray

#3 CalumT

CalumT
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 April 2006 - 12:28 PM

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

so it should be

$ipaddress = gethostbyname ('$site');

Ray
[/quote]

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

The IP address of microsoft.com is $site

Any ideas?

#4 kayess2004

kayess2004
  • Members
  • PipPip
  • Member
  • 18 posts
  • LocationAustralia

Posted 28 April 2006 - 12:53 PM

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

The IP address of microsoft.com is $site

Any ideas?
[/quote]

Hi,
Remove the quotes

$ipaddress = gethostbyname($site);

HTH
Chuck Norris doesn't know love. Chuck Norris only knows not kill.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users