ip2long function help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tomindo
Forum Newbie
Posts: 13
Joined: Sun Mar 21, 2010 1:22 am

ip2long function help

Post by tomindo »

it does not echo the ip conversions. I tried without ip2long functino , it worked fine

Code: Select all

<form method="post" action="test.php"> 
<textarea name="new" cols="40" rows="10"> 
samplehost-1,127.0.0.1
samplehost-2,127.0.0.2
</textarea><br>
<input type="submit" value="Add Servers"> 
</form>
<?phpif(isset($_POST['new'])) {
	$array= explode("\n",$_POST['new']);
	foreach ($array as $ni) {
				$array=explode(',', $ni);
				echo ip2long($array[1]);	
}
}
?>
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: ip2long function help

Post by Darhazer »

most likely, ip2long returns false, and this is why echo does not work
you can use var_dump() to check
The same way check the value of $array[1]
tomindo
Forum Newbie
Posts: 13
Joined: Sun Mar 21, 2010 1:22 am

Re: ip2long function help

Post by tomindo »

thanks
Post Reply