开发者

Updating MYSQL Database fail, why?

开发者 https://www.devze.com 2023-01-28 05:18 出处:网络
$serverid = mysql_query(\"SELECT * FROM serveripank\"); while($row = mysql_fetch_array($serverid)) { require_once(\'../getdata/cs-getdata.php\');
$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']

0

精彩评论

暂无评论...
验证码 换一张
取 消