ahill Posted February 15, 2009 Share Posted February 15, 2009 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 More sharing options...
killah Posted February 15, 2009 Share Posted February 15, 2009 In php script 2. Where is $get_info[$i] being declared? Because as far as i can see it's being declared in script 1. Maybe in script 2 include the script 1 and then try? Link to comment https://forums.phpfreaks.com/topic/145295-solved-php-mysql-help-fsockopen/#findComment-762796 Share on other sites More sharing options...
ahill Posted February 15, 2009 Author Share Posted February 15, 2009 script 2 is included in script 1 include ('users.php'); = script 2 Link to comment https://forums.phpfreaks.com/topic/145295-solved-php-mysql-help-fsockopen/#findComment-762910 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.