Page 1 of 1

Peculiar problem with working of php

Posted: Tue Jun 21, 2005 12:12 pm
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?

Posted: Tue Jun 21, 2005 12:15 pm
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.

Posted: Tue Jun 21, 2005 12:19 pm
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.

Posted: Tue Jun 21, 2005 12:20 pm
by Burrito
did you try removing the @ on the server version?

Posted: Tue Jun 21, 2005 12:23 pm
by srirams
Yes I did. But still the same result.
Not getting any error. Getting both the conditions displayed.

Posted: Tue Jun 21, 2005 12:28 pm
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?

Posted: Tue Jun 21, 2005 12:31 pm
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.

Posted: Tue Jun 21, 2005 12:33 pm
by srirams
I am just wondering about the main site ignoring the if and else code?
what could be wrong in the server.

Posted: Tue Jun 21, 2005 12:36 pm
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.

Posted: Tue Jun 21, 2005 12:39 pm
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?

Posted: Tue Jun 21, 2005 12:42 pm
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.

Posted: Tue Jun 21, 2005 12:45 pm
by srirams
Ok. I have just added you on MSN.

Yes its a windows machine.