Peculiar problem with working of php
Moderator: General Moderators
Peculiar problem with working of php
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?
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?
I just did it on my machine and got this
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?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
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.
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.