Author Topic: Function not working correctly  (Read 137 times)

TheRoyalNoob

  • New Member
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Function not working correctly
« on: May 04, 2012, 11:45:11 PM »
Now I usually don't use functions but I am just trying them out.

Now what I am trying to do is make it easy to execute the function using the defined values but it always returns as online regardless of the value I use.

PHP Code: [Select]
function grabStatus($server$portn) {
$ip "$server";
$port "$portn";
echo 
"Server:";
if (! 
$sock = @fsockopen($ip$port$num$error5)) {
	
echo 
"Online";
	
} else {
	
echo 
"Offline";
	
}
}

grabStatus(/* a server ip */8023); //randomly picked port that is not being utilized 


I'd appreciate help. I do understand how functions work to an extent, I just don't know why this isn't working for me.

richei

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 1133
  • Karma: 22
    • View Profile
Re: Function not working correctly
« Reply #1 on: May 05, 2012, 12:08:08 AM »
look at what you have. its going to report back that its online because its being told that if it fails that the server is online.  just remove the ! and it should say that its offline.