Jump to content

Archived

This topic is now archived and is closed to further replies.

CalumT

Problem with domain to IP address translator!

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

Share this post


Link to post
Share on other sites
gethostbyname requires enclosed ().

so it should be

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

Ray

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.