$serverid = mysql_query("SELECT * FROM serveripank");
while($row = mysql_fetch_array($serverid)) {
require_once('../getdata/cs-getdata.php');
$result = $cstrike->getData();
$SNAME = $result['cstrike']['ServerVars']['servername']; //Server name
$SMAP = $result['cstrike']['ServerVars']['mapname']; //Map name
$SCP = $result['cstrike']['ServerVars']['currentplayers']; //Server Current Players
$SMP = $result['cstrike']['ServerVars']['maxplayers']; //Server Max Players
// Servers name MAX 25 letters & Map
$SNAME = substr($SNAME, 0, 25);
$SMAP = substr($SMAP, 0, 20);
$id = $row['id'];
mysql_query("UPDATE serveripank SET players = '$SCP' WHERE id = '$id'");
mysql_query("UPDATE serveripank SET maxplayers = '$SMP' WHERE id = '$id'");
mysql_query("UPDATE serveripank SET map = '$SMAP' WHERE id = '$id'");
mysql_query("UPDATE serveripank SET srname = '$SNAME' WHERE id = '$id'");
}
Im using this script http://dev.ush-network.de/2010/02/02/gathering-counter-strike-data-using-php-sockets/comment-page-1/#comment-22 in require_once('../getdata/cs-getdata.php');
When i go to the link to update my MYSQL database, it doesnt display any errors but in database the rows are empty.
This is in my cs-getdata.php file @ the bottom, so it could update all the servers with the right values... ( Dont know how to explain better )
list($ip, $port) = explode(":", "row['ip']"); $cstrike = new cstrike_statistics(); $cstrike->setHostname('$ip'); $cstrike->setPort($port);
My problem is that it doesnt get the server info / and it puts empty values to the database.
Oh my god, why didnt anyone notice my silly mistake?
list($ip, $port) = explode(":", "row['ip']");
$cstrike = new cstrike_statistics();
$cstrike->setHostname('$ip');
$cstrike->setPort($port);
should be
list($ip, $port) = explode(":", "$row['ip']");
$cstrike = new cstrike_statistics();
$cstrike->setHostname('$ip');
$cstrike->setPort($port);
Mistake was: $row['ip']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.