Peculiar problem with working of php

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
srirams
Forum Commoner
Posts: 36
Joined: Wed May 25, 2005 8:57 am
Location: India
Contact:

Peculiar problem with working of php

Post by srirams »

Hi all,
I am facing a peculiar problem with some of the things not working in the main server , but works perfectly in the local machine.
For example:

<? $cmssite = @fsockopen("cmsweb.gci.db.com", 80, $errno, $errstr, 30);
if(!$cmssite)
{?>
<td valign=top width="6%"><img src=bulletred.gif width=15 height=15 border=0></td>
<?}
else
{?>
<td valign=top width="6%"><img src=bulletgreen.gif width=15 height=15 border=0>The site is up and running</td>
<? } ?>

The result of this code in my local machine gives as color green and displays The site is up and running. But the same code in the main server is displaying both the colors next to each other which means its not looking at the if statement at all. If I have to think that php is not installed properly in that box , then the site itself shouldn't be coming up. The name of the file is index.php and its coming up properly.

What could be the problem in the server?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

please use PHP tags...makes it much easier to read.

try removing the @ in front of your fsockopen and see if it returns any errors.
srirams
Forum Commoner
Posts: 36
Joined: Wed May 25, 2005 8:57 am
Location: India
Contact:

Post by srirams »

Actully I tried even without @ and it works.
But my question is when it can work well in my local machine why doesn't it work in the server.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

did you try removing the @ on the server version?
srirams
Forum Commoner
Posts: 36
Joined: Wed May 25, 2005 8:57 am
Location: India
Contact:

Post by srirams »

Yes I did. But still the same result.
Not getting any error. Getting both the conditions displayed.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I just did it on my machine and got this
Warning: fsockopen(): php_network_getaddresses: gethostbyname failed in c:\inetpub\wwwroot\glob.php on line 1

Warning: fsockopen(): unable to connect to cmsweb.gci.db.com:80 in c:\inetpub\wwwroot\glob.php on line 1
when I changed the address to http://www.yahoo.com it worked fine. I then tried hitting the address you had from my web browser and it didn't come up. Finally I tried pinging it and host could not be found. Are you sure it's a public domain? maybe you have a host entry set up with the proper ip on your local macine?
srirams
Forum Commoner
Posts: 36
Joined: Wed May 25, 2005 8:57 am
Location: India
Contact:

Post by srirams »

Actually thats a local site cmsweb.gci.db.com runs in our network. SO it works for me. The main server I was talking about is also in the network.
The localmachine where I am trying is my machine where I am running the code.
srirams
Forum Commoner
Posts: 36
Joined: Wed May 25, 2005 8:57 am
Location: India
Contact:

Post by srirams »

I am just wondering about the main site ignoring the if and else code?
what could be wrong in the server.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

are you sure it resolves from the server?

if so and you've narrowed down all other possiblities (tried turning error_reporting on and removed the @), you might need to pass some headers when you call the page with fsockopen....it seems counterintuitive that it'd work from your local machine and not the server (the header idea), but stranger thigns have happened.

maybe try goign to the server and hitting that address from a browser to ensure that it resolves correctly and that you indeed pull up a page.
srirams
Forum Commoner
Posts: 36
Joined: Wed May 25, 2005 8:57 am
Location: India
Contact:

Post by srirams »

lol.
Th server is in US and I am sitting in UK.
Just that it belongs to the same domain of DB network.

I am getting really confused. I have tried everything.

Anyways Thanks a lot for the help.
Do you have yahoo messenger?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

is it a windows server? If so, use term services and jump on it and try it. If *nix, open a shell and jump in and try it...

no I only have MSN.
srirams
Forum Commoner
Posts: 36
Joined: Wed May 25, 2005 8:57 am
Location: India
Contact:

Post by srirams »

Ok. I have just added you on MSN.

Yes its a windows machine.
Post Reply