Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
fsockopen not work if IP from database?
Old 08-23-2008, 05:38 PM fsockopen not work if IP from database?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
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 <<

Please login or register to view this content. Registration is FREE

Last edited by dansgalaxy; 08-23-2008 at 06:05 PM..
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
 
Register now for full access!
Old 08-23-2008, 08:13 PM Re: fsockopen not work if IP from database?
blackfalcon's Avatar
Skilled Talker

Latest Blog Post:
New Site: 10DollarBluRay.com
Posts: 62
Name: JuanJose H. Galvez
Trades: 0
Hey Dan,

Just thought I'd throw in a quick suggestion, since you seem to have to only trim when you get the information from the database, you may want to check the script that does the DB insert. Somewhere along the way that extra space is being added and it shouldn't really get into the DB in the first place.

Maybe use the trim() BEFORE it goes into the DB?

JJ!
__________________
Latest Project:
Please login or register to view this content. Registration is FREE
<--CHECK IT OUT!
My Company:
Please login or register to view this content. Registration is FREE

I'm
Please login or register to view this content. Registration is FREE
blackfalcon is offline
Reply With Quote
View Public Profile Visit blackfalcon's homepage!
 
Old 08-23-2008, 08:31 PM Re: fsockopen not work if IP from database?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Nah thats not it... because at the moment i havnt created the admin side, so its direct DB input (PMA)

and i double checked and it doesnt seem to have a space in DB...

So im a little clueless to be honest lol

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 08-23-2008, 08:36 PM Re: fsockopen not work if IP from database?
blackfalcon's Avatar
Skilled Talker

Latest Blog Post:
New Site: 10DollarBluRay.com
Posts: 62
Name: JuanJose H. Galvez
Trades: 0
Weird! Seriously confusing little error that. Well, good luck with your programming.

JJ
__________________
Latest Project:
Please login or register to view this content. Registration is FREE
<--CHECK IT OUT!
My Company:
Please login or register to view this content. Registration is FREE

I'm
Please login or register to view this content. Registration is FREE
blackfalcon is offline
Reply With Quote
View Public Profile Visit blackfalcon's homepage!
 
Reply     « Reply to fsockopen not work if IP from database?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13978 seconds with 12 queries