Problem with serverinfo

ptR

Member
Joined
Nov 15, 2015
Messages
47
Reaction score
0
Points
38
Somebody please help me!


Code:
<?php
            $ts3_ip = 'xx.xxx.xxx.xxx';
            $ts3_queryport = 10011;
            $ts3_user = 'serveradmin';
            $ts3_pass = 'asd';
            $ts3_port = 9987;
            $ts3_sid = 2;
            $tsAdmin = new ts3admin($ts3_ip, $ts3_queryport);

            if($tsAdmin->getElement('success', $tsAdmin->connect())) {
            $tsAdmin->login($ts3_user, $ts3_pass);
            $server = $tsAdmin->serverInfo();
            $output = 0;
            $output = $server['virtualserver_name'];
            }else{
                echo 'Connection could not be established.';
            }
           
            ?>
            <?PHP echo $output; ?>

Its not working whats the problem?
 

FarisDev

L oryh brx
Contributor
Joined
Jun 9, 2016
Messages
277
Reaction score
111
Points
107
What is This "$output = 0; " for? Just remove it, and try!
 

ptR

Member
Joined
Nov 15, 2015
Messages
47
Reaction score
0
Points
38
Code:
Notice: Undefined index: virtualserver_name in C:\path\to\file.php on line 35
 

Kleberstoff

Knowledge Seeker
VIP
Joined
Dec 29, 2015
Messages
308
Reaction score
214
Points
158
Anymore details? Like errors?

edit: never mind.

can you post the entire file?
 
Last edited:

ptR

Member
Joined
Nov 15, 2015
Messages
47
Reaction score
0
Points
38
nothing errors just it shows me: Notice: Undefined index: virtualserver_name in C:\path\to\file.php on line 36

Code:
            <?php
            $ts3_ip = 'xx.xxx.xxx.xxx';
            $ts3_queryport = 10011;
            $ts3_user = 'serveradmin';
            $ts3_pass = '******';
            $ts3_port = $row['serverPort'];
            $ts3_sid = $row['serverId'];
            require("ts3admin.class.php");
            echo $row['serverId']; echo "</br>";
            echo $row['serverPort'];
            error_reporting(E_ALL);
            ini_set('display_errors', 1);
            if($tsAdmin->getElement('success', $tsAdmin->connect())) {
            $tsAdmin->login($ts3_user, $ts3_pass);
            $server = $tsAdmin->serverInfo();
            $output = $server['virtualserver_name'];
            }else{
                echo 'Connection could not be established.';
            }
          
            ?>
<?PHP echo $output; ?>
 
Last edited:

Kleberstoff

Knowledge Seeker
VIP
Joined
Dec 29, 2015
Messages
308
Reaction score
214
Points
158
nothing errors just it shows me: Notice: Undefined index: virtualserver_name in C:\path\to\file.php on line 36

Code:
            <?php
            $ts3_ip = 'xx.xxx.xxx.xxx';
            $ts3_queryport = 10011;
            $ts3_user = 'serveradmin';
            $ts3_pass = '******';
            $ts3_port = $row['serverPort'];
            $ts3_sid = $row['serverId'];
            require("ts3admin.class.php");
            echo $row['serverId']; echo "</br>";
            echo $row['serverPort'];
            error_reporting(E_ALL);
            ini_set('display_errors', 1);
            if($tsAdmin->getElement('success', $tsAdmin->connect())) {
            $tsAdmin->login($ts3_user, $ts3_pass);
            $server = $tsAdmin->serverInfo();
            $output = $server['virtualserver_name'];
            }else{
                echo 'Connection could not be established.';
            }
         
            ?>
<?PHP echo $output; ?>

the $server variable doesn't have ['virtualserver_name'] in it, check it using 'var_dump($server)'.
 

ptR

Member
Joined
Nov 15, 2015
Messages
47
Reaction score
0
Points
38
so i need dumping? can u write an example for me i dont know i try it but its not working for me..
 

Kleberstoff

Knowledge Seeker
VIP
Joined
Dec 29, 2015
Messages
308
Reaction score
214
Points
158
so i need dumping? can u write an example for me i dont know i try it but its not working for me..

try this:

Code:
           <?php
           $ts3_ip = 'xx.xxx.xxx.xxx';
           $ts3_queryport = 10011;
           $ts3_user = 'serveradmin';
           $ts3_pass = '******';
           $ts3_port = $row['serverPort'];
           $ts3_sid = $row['serverId'];
           require("ts3admin.class.php");
           echo $row['serverId']; echo "</br>";
           echo $row['serverPort'];
           error_reporting(E_ALL);
           ini_set('display_errors', 1);
           if($tsAdmin->getElement('success', $tsAdmin->connect())) {
           $tsAdmin->login($ts3_user, $ts3_pass);
           $server = $tsAdmin->serverInfo();
           var_dump($server);
           $output = $server['virtualserver_name'];
           }else{
               echo 'Connection could not be established.';
           }
      
           ?>
<?PHP echo $output; ?>

It'll give either a lot of information or nothing at all :^)
 

ptR

Member
Joined
Nov 15, 2015
Messages
47
Reaction score
0
Points
38
ohh sorry i didnt see it :D

It wrote this: array(3) { ["success"]=> bool(false) ["errors"]=> array(1) { [0]=> string(52) "you can't use this function if no server is selected" } ["data"]=> bool(false) }
 

Kleberstoff

Knowledge Seeker
VIP
Joined
Dec 29, 2015
Messages
308
Reaction score
214
Points
158
ohh sorry i didnt see it :D

It wrote this: array(3) { ["success"]=> bool(false) ["errors"]=> array(1) { [0]=> string(52) "you can't use this function if no server is selected" } ["data"]=> bool(false) }

As the error said, it doesn't work because you don't have server selected. I never worked with ts3admin.class but there should be a documentation on they website.
 

ptR

Member
Joined
Nov 15, 2015
Messages
47
Reaction score
0
Points
38
i read that documentation but i cant understand it. When i did that it wrote its not working ... Now i tried selecting a server but after dont working too
 

Kleberstoff

Knowledge Seeker
VIP
Joined
Dec 29, 2015
Messages
308
Reaction score
214
Points
158
try
Code:
          <?php
          $ts3_ip = 'xx.xxx.xxx.xxx';
          $ts3_queryport = 10011;
          $ts3_user = 'serveradmin';
          $ts3_pass = '******';
          $ts3_port = $row['serverPort'];
          $ts3_sid = $row['serverId'];
          require("ts3admin.class.php");
          echo $row['serverId']; echo "</br>";
          echo $row['serverPort'];
          error_reporting(E_ALL);
          ini_set('display_errors', 1);
          if($tsAdmin->getElement('success', $tsAdmin->connect())) {
          $tsAdmin->login($ts3_user, $ts3_pass);
          $tsAdmin = $tsAdmin->selectServer ($row['serverPort']);
          $server = $tsAdmin->serverInfo();
          var_dump($server);
          $output = $server['virtualserver_name'];
          }else{
              echo 'Connection could not be established.';
          }
    
          ?>
<?PHP echo $output; ?>

It may not work, but it should.
 

ptR

Member
Joined
Nov 15, 2015
Messages
47
Reaction score
0
Points
38
Call to a member function serverInfo() on a non-object in C:\xampp\htdocs\aa\dashboard.php on line 39
 

FarisDev

L oryh brx
Contributor
Joined
Jun 9, 2016
Messages
277
Reaction score
111
Points
107
ptR why you aren't using The Teamspeak3 PHP Framework, it's better than ts3admin.class and very easy to use, I think you need to display server information on your web?, it's pretty easy with Teamspeak3 Framework! Example:
PHP:
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$ts3 = TeamSpeak3::factory("serverquery://username:[email protected]:10011/?server_port=9987");
$servername = $ts3["virtualserver_name"];
echo $servername;
I don't test it, But it's should work!
Only edit ts3 connection code.
It's only got the server name of the Teamspeak3 server and disconnect.
Requirements:
PHP, Teamspeak3 Php framework.
 

ptR

Member
Joined
Nov 15, 2015
Messages
47
Reaction score
0
Points
38
I want use it becouse its faster and i have to options to start/stop etc.. i used that
 

FarisDev

L oryh brx
Contributor
Joined
Jun 9, 2016
Messages
277
Reaction score
111
Points
107
Okay, Teamspeak3 PHP Framework is faster too!
 

ptR

Member
Joined
Nov 15, 2015
Messages
47
Reaction score
0
Points
38
Code:
<?php
   
require("ts3admin.class.php");
$ts3_ip = 'xx.xxx.xxx.xxx';
$ts3_queryport = 10011;
$ts3_user = 'serveradmin';
$ts3_pass = 'xxxxxxx';
$ts3_port = 9987;
$ts3_sid = 2;
$tsAdmin = new ts3admin($ts3_ip, $ts3_queryport);
$tsAdmin->selectServer($ts3_sid);
$serverInfo = $tsAdmin->serverInfo();
echo "</br>";
echo $serverInfo["virtualserver_name"];
?>

It wrote : Undefined index virtualserver_name.. What the hell what the problem? I really dont understand it..
 

domex85

Member
Joined
Sep 10, 2015
Messages
6
Reaction score
1
Points
35
use $serverInfo['data']['virtualserver_name'] to get hostname
 
Top