Warning: Missing argument 2 for server_online()

Ask about a PHP problem here.
Post Reply
SnipeLike
Posts: 2
Joined: Wed Jan 16, 2013 7:28 pm

Warning: Missing argument 2 for server_online()

Post by SnipeLike »

hi

i got allways the same warning on my php page: :?:

Warning: Missing argument 2 for server_online(), called in C:\xampp\htdocs\index.php on line 137 and defined in C:\xampp\htdocs\minecraftserver.inc.php on line 3

Warning: fsockopen(): unable to connect to 25565:0 (Failed to parse address "25565") in C:\xampp\htdocs\minecraft_server.inc.php on line 4

this is my minecraftserver.inc.php:

[syntax=php]<?php
function server_online($server, $port){
fsockopen($server, $port, $errno, $errstr);

return ($errno === 0);
}
?>[/syntax]

heres my index.php:


[syntax=php]<?php
var_dump(server_online($servers[0][1]));
?>
[/syntax]

and my init.inc.php:

[syntax=php]
<?php
$servers = array(
array('server.no-ip.org', '25565'),
);

$path = dirname(__FILE__);

include("{$path}\minecraftserver.inc.php");

?>[/syntax]

can you halp me pls?

thank you,
Sl
ExtremeGaming
Posts: 205
Joined: Mon Jul 09, 2012 11:13 pm

Re: Warning: Missing argument 2 for server_online()

Post by ExtremeGaming »

The error message says it all. You are defining the function here:
[syntax=php]<?php
function server_online($server, $port){
fsockopen($server, $port, $errno, $errstr);

return ($errno === 0);
}
?>[/syntax]

Note that you have two arguments when defining it. $server, and $port. Now, when you are using it here:
[syntax=php]<?php
var_dump(server_online($servers[0][1]));
?>
[/syntax]

Note that you are only using one argument. Also note that you aren't defining $servers, $errno, or $errstr anywhere visible.
<?php while(!$succeed = try()); ?>
SnipeLike
Posts: 2
Joined: Wed Jan 16, 2013 7:28 pm

Re: Warning: Missing argument 2 for server_online()

Post by SnipeLike »

ExtremeGaming wrote:The error message says it all. You are defining the function here:
[syntax=php]<?php
function server_online($server, $port){
fsockopen($server, $port, $errno, $errstr);

return ($errno === 0);
}
?>[/syntax]

Note that you have two arguments when defining it. $server, and $port. Now, when you are using it here:
[syntax=php]<?php
var_dump(server_online($servers[0][1]));
?>
[/syntax]

Note that you are only using one argument. Also note that you aren't defining $servers, $errno, or $errstr anywhere visible.


thx for your fast answer! :D
and thx for your help ;)

so it works now...
~this post can be closed~
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Warning: Missing argument 2 for server_online()

Post by Helx »

Threads don't necessarily need to be closed when the question is answered.
Post Reply