PHP + IIS = no "fsockopen" *help*

911paramedic

Diamond Member
Jan 7, 2002
9,448
1
76
I have php 4.3.3 installed on IIS 5.1. I try to run a script that requires an fsockopen command but only get back ...
Notice: Undefined variable: tmpinfo in c:\inetpub\wwwroot\serverinfo\scanner.inc.php on line 18

Notice: Use of undefined constant gamever - assumed 'gamever' in c:\inetpub\wwwroot\serverinfo\scanner.inc.php on line 19

Notice: Undefined variable: tmpinfo in c:\inetpub\wwwroot\serverinfo\scanner.inc.php on line 19

Notice: Use of undefined constant location - assumed 'location' in c:\inetpub\wwwroot\serverinfo\scanner.inc.php on line 20

Notice: Undefined variable: tmpinfo in c:\inetpub\wwwroot\serverinfo\scanner.inc.php on line 20

Notice: Use of undefined constant official - assumed 'official' in c:\inetpub\wwwroot\serverinfo\scanner.inc.php on line 21
I know this script works because when uploaded to my paid server it's fine. My only guess is that my personal computer that I have IIS running on does not allow the remote server queries, I even shut down my XP firewall to see if that was the problem, no go.

Here are the specs:

XP pro
PHP 4.3.3
IIS 5.1
Lynksys Router <-- could this be the problem?

Any ideas??? :confused:

P.S. Heres a snippet of the code it's working with...

<?PHP
ob_start();
$connection = fsockopen("udp://$serveripaddress",$serverqueryport);
fwrite($connection,"\\status\\");
socket_set_timeout($connection, $ws_querytimeout);
fpassthru($connection);
$strOutput = ob_get_contents();
$tmp=explode("\\",$strOutput);
ob_end_clean();

for($i=1;$i<count($tmp);$i++) {
$varname=$tmp[$i];
$i++;
$tmpinfo[$varname]=$tmp[$i];
}

// sync Serverlist with GameserverQuery-protocol
$serverinfo[hostname] = $tmpinfo["hostname"];
$serverinfo[gamever] = $tmpinfo["gamever"];
$serverinfo[location] = $tmpinfo["location"];
$serverinfo[official] = $tmpinfo["official"];
$serverinfo[leased] = $tmpinfo["leased"];
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
The error message you got has nothing to do with fsockopen() not working. It's saying there are errors with your other lines of codes. As far as I know, fsockopen() works on Windows as well.

Ok, let's see.. are hostname, gamever, location, official, and leased defined constants?

You use them as indices in the array $serverinfo[] as they are defined constants. That's what the error message is complaining about. Maybe you meant to put $serverinfo['hostname']?
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
foreach(array("hostname", "gamever", "location", "official", "leased") as $key)
$serverinfo[$key] = $tmpinfo[$key];
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
*sigh*

Can you be more specific than just saying that you can't get it to work?
 

eklass

Golden Member
Mar 19, 2001
1,218
0
0
notices are non-fatal

looks to me that error reporting is set to E_ALL in your php.ini
an easy fix is to change error reporting to E_ERROR
the good fix is to get rid of the notices by coding properly
 

911paramedic

Diamond Member
Jan 7, 2002
9,448
1
76
I'll try that error setting later today. The code works fine when it's uploaded, so I'm guessing my personal server is set up wrong.

The page in action. (the rest of the site is still in development, so don't worry about the other pages :p)