Jump to content

[SOLVED] PHP - MySql Help - fsockopen()


ahill

Recommended Posts

Hi, basically im wanting a php script that will read several rows from my Mysql database that consist of several ip's. i then want it to do an fsockopen() check on all the ip's (using same port though) and then update a field in the sql database with the given information.

 

basically its a script that updates the users online count in a mysql database.

 

 

heres what i have so far, but it seems to just do the fsockopen() check for the first ip returned from the mysql database.

 

PHP Script 1:

<?
error_reporting(E_ERROR);
include ('dbc.php');
$countquery = sprintf("SELECT `server_ip` FROM `users` WHERE user_activated=1");

$countresult = mysql_query($countquery)
or die("SELECT Error: ".mysql_error());
$num=mysql_numrows($countresult); 
while ($get_info = mysql_fetch_array($countresult, MYSQL_NUM)){
$i=0; 
while ($i < $num) { 
foreach ($get_info as $field) 

mysql_query("UPDATE users SET user_count='$users' WHERE server_ip='$get_info[$i]'") or die(mysql_error());

print $get_info[$i];
include ('users.php');
print '</p>';
print $users;
print '</p>';
}
}
print "\n";
mysql_close($link);
?>

 

PHP Script 2:

<?
error_reporting(E_ERROR);

$connect = fsockopen($get_info[$i], 3000, $errno, $errstr, 5 );
	$soutput .= fread($connect,100);
	$data = explode("/", $soutput);
	$sdata = explode(";", $data[0]);
	$ssdata = explode(";", $data[3]);
	$stype = $data[3];
	$sstype = $ssdata[0];
	if ($stype == "DiamondM2")
	{
	$users = $data[8];
	} else {
	if ($sstype == "GOOD")
	{
	$users = $data[5];
	} else {
	if ($sstype == "U}3# ")
	{
	$users = $data[8];
	}
	}
	}
?>

Link to comment
https://forums.phpfreaks.com/topic/145295-solved-php-mysql-help-fsockopen/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.