Jump to content

querying every server listed in the sql


Septharoth

Recommended Posts

<?php
include 'core/classes/Query.php';
include 'core/functions/recaptchalib.php';
	
$sqlQ = "SELECT * FROM `servers`";
$qResult = $database->query($sqlQ);
$i = 0;
while ($row = $qResult->fetch_assoc()) {
$query = new Query($row['address'], $row['query_port'], $row['engine']);
$info  = $query->query();

if(!$info) {	
	$info = $query->return_false();
}
	
	$details = array(
			'players' => $info['players'],
			'details' => $info['details']
		);
	$details = json_encode($details);
		

	$update = $database->prepare("UPDATE `servers` SET `status` = ?, `online_players` = ?, `maximum_online_players` = ?, `map` = ?, `details` = ?, `cachetime` = unix_timestamp() WHERE `server_id` = {$row['server_id']}"
	$update->bind_param('sssss', $query->status, $info['general']['online_players']['value'], $info['general']['maximum_online_players']['value'], $info['general']['map']['value'], $details)
	$update->execute(); }
?>

		

What I'm trying to accomplish is query every server & update every one of the rows for each server listed.  This does nothing

( its a cronjob , as it has to run every 5 minutes , newbie so not entirely sure if this is event the right approach )

Link to comment
https://forums.phpfreaks.com/topic/293228-querying-every-server-listed-in-the-sql/
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.