FIXED: It seems for some reason a empty space is added to the variable :s, just trim() it before it goes into fsockopen and seems to work =/
okay this is doing my head in now because i dont understand why it doesnt work.
PHP Code:
$result = $db->query("SELECT * FROM servers WHERE id='$server_id' OR name='$server_id'"); $row = $db->fetch_row($result); $server_ip = $row['ip']; //this is the site you wish to check $server_ip1="91.197.32.125"; $fp = fsockopen($server_ip1,"80"); if($fp) { $status1 = '1'; } else { $status1 = '0'; } fclose($fp); echo 'normal: '.$status1; echo '<hr />'; $fp = fsockopen($server_ip, "80"); if($fp) { $status = '1'; } else { $status = '0'; } fclose($fp); echo 'DB:'.$status;
First one works fine, the second which gets IP from database doesnt.
Ips are the same.
What could be wrong?
IP is stored as varchar in db.
it displays like this:
Code:
normal: 1
Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/USER/public_html/SwinServe/serverstats.php on line 52
Warning: fsockopen() [function.fsockopen]: unable to connect to 91.197.32.125:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /home/USER/public_html/SwinServe/serverstats.php on line 52
Warning: fclose(): supplied argument is not a valid stream resource in /home/USER/public_html/SwinServe/serverstats.php on line 59
DB:0
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
Last edited by dansgalaxy; 08-23-2008 at 06:05 PM..
|