MineQuery

Ask about a PHP problem here.
Post Reply
JonnyUK
Posts: 6
Joined: Fri Nov 16, 2012 5:57 pm

MineQuery

Post by JonnyUK »

I've followed all tutorials on this and I'm still getting this error!

37.220.18.188

Status: Online

Slots: /

Players:
Warning: implode() [function.implode]: Invalid arguments passed in /home/dnurtcom/public_html/dom/Server/index.php on line 31

http://evolutionservers.net/Server.zip
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: MineQuery

Post by Temor »

Post your code here using [syntax=text][syntax=php][/syntax][/syntax] tags.
JonnyUK
Posts: 6
Joined: Fri Nov 16, 2012 5:57 pm

Re: MineQuery

Post by JonnyUK »

Index.php
[syntax=php]<?php
include ('core/init.inc.php');

$info = fetch_server_info($config['server']['ip'], $config['server']['port']);

?>
<html>
<head>
<title><?php echo $config['server']['ip']; ?> Status</title>
</head>
<body>
<div>
<h1><?php echo $config['server']['ip']; ?></h1>

<?php
if ($info = false){
?>
<p>
Status: Offline
</p>
<?php
}else{
?>
<p>
Status: Online
</p>
<p>
Slots: <?php echo $info['playerCount'];?> / <?php echo $info['maxPlayers'];?>
</p>
<p>
Players: <?php echo implode('', $info['playerList']);?>
</p>
<?php
}
?>
</div>
</body>
</html>[/syntax]

error_log
[syntax=php][16-Nov-2012 12:02:30 America/Chicago] PHP Warning: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in /home/dnurtcom/public_html/dom/Server/index.php on line 31[/syntax]

init.inc.php
[syntax=php]<?php
$path = dirname(__FILE__);

include ("{$path}/config.inc.php");
include ("{$path}/inc/mc.inc.php");
?>[/syntax]

config.inc.php
[syntax=php]<?php
$config['server']['ip'] = '37.220.18.188';
$config['server']['port'] = '25565';
?>[/syntax]

mc.inc.php
[syntax=php]<?php

// fetches server information from minequery.
function fetch_server_info($ip, $port){
$socket = fsockopen($ip, $port, $errno, $errstr, 0.5);

if($socket == false){
return false;
}

fwrite($socket, "QUERY_JSON\n");

$response = stream_get_contents($socket);

return json_decode($response, true);
}
?>[/syntax]
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: MineQuery

Post by Temor »

Do you get the values you were expecting from $info['playerCount'] and $info['maxPlayers'] ?
JonnyUK
Posts: 6
Joined: Fri Nov 16, 2012 5:57 pm

Re: MineQuery

Post by JonnyUK »

User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: MineQuery

Post by Temor »

if you dump the $info variable, do you get bool(false) ?

[syntax=php]var_dump($info);[/syntax]
JonnyUK
Posts: 6
Joined: Fri Nov 16, 2012 5:57 pm

Re: MineQuery

Post by JonnyUK »

Yes I do, check that link I provided
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: MineQuery

Post by Temor »

that means that the function is failing, which means one of these things:
1 You have the wrong IP
2 You have the wrong PORT
3 You don't have access to said IP or PORT
4 The server is down.

Check that everything is correct.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: MineQuery

Post by jacek »

[syntax=php]$config['server']['port'] = '25565';[/syntax]
25565 is the default port for Minecraft, MineQuery runs on 25566 by default so maybe that is worth a try ?
Image
JonnyUK
Posts: 6
Joined: Fri Nov 16, 2012 5:57 pm

Re: MineQuery

Post by JonnyUK »

Is there anything that I need to do server side?
JonnyUK
Posts: 6
Joined: Fri Nov 16, 2012 5:57 pm

Re: MineQuery

Post by JonnyUK »

Now the var_dump says NULL
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: MineQuery

Post by jacek »

JonnyUK wrote:Is there anything that I need to do server side?

Install MineQuery ? http://dev.bukkit.org/server-mods/minequery/
Image
Post Reply