0

I have big problem because, when I'm trying to show status of my ts3 server I have blank page... What am I doing wrong?

require_once('libraries/TeamSpeak3/TeamSpeak3.php');
try
        {
          // connect to server, authenticate and grab info
          $ts3 = TeamSpeak3::factory("serverquery://query_admin:query_pass@host:10011/?server_port=9987");

          // show server as online
            $serverinfo[$j]['hostname'] = $ts3->virtualserver_name;
            $serverinfo[$j]['online'] = 'online';
            $serverinfo[$j]['players'] = $ts3->virtualserver_clientsonline;
            $serverinfo[$j]['max'] = $ts3->virtualserver_maxclients;

        }
        catch(Exception $e)
        {
          // grab errors and show server as offline
            $serverinfo[$j]['online'] = 'offline';
            $serverinfo[$j]['players'] = '-';
            $serverinfo[$j]['max'] = '-';
        }

When I comment this code the page shows as normal...

EDIT: I see it now, if I only add this require_once('libraries/TeamSpeak3/TeamSpeak3.php'); and nothing more to my code it shows blank page... Is it possible, that library from here doesn't work properly?

pusty
  • 45
  • 7
  • Syntax error. Missing a `'` in `require_once(libraries/TeamSpeak3/TeamSpeak3.php');` – ʰᵈˑ Oct 07 '15 at 08:37
  • that's not it, I correcy that, and nothing change... – pusty Oct 07 '15 at 08:40
  • What debugging have you done? Have you changed the string in `TeamSpeak3::factory`? I guess you've c&p this and expected it to point your own ts3 server automatically...? – ʰᵈˑ Oct 07 '15 at 08:43
  • I see it now, if I only add this require_once('libraries/TeamSpeak3/TeamSpeak3.php'); and nothing more to my code it shows blank page... Is it possible, that library from here doesn't work properly? – pusty Oct 07 '15 at 08:48
  • Sure, it's possible. But without supplying that code, I'm speculating... – ʰᵈˑ Oct 07 '15 at 08:50
  • code of all library I use: http://addons.teamspeak.com/directory/addon/integration/TeamSpeak-3-PHP-Framework.html – pusty Oct 07 '15 at 08:51
  • What PHP version are you running? – ʰᵈˑ Oct 07 '15 at 08:56
  • Put `ini_set('display_errors', 1); error_reporting(E_ALL);` at the top of your file before the `require_once` and see if any errors come back (if you're not on a production server). Also, I'm assuming you've changed `serverquery://query_admin:query_pass@host:10011/?server_port=9987` to have your host, user, and pass - and that port 9987 is open (`o 9987` (windows) `telnet 9987` (linux) or use [https://www.shodan.io/](https://www.shodan.io/)) – ʰᵈˑ Oct 07 '15 at 09:02
  • I see the problem is not in the code, the problem starts when I add require_once('libraries/TeamSpeak3/TeamSpeak3.php'); line to my code. When I add this, it makes blank page and no errors are displayed. – pusty Oct 07 '15 at 09:06
  • Make sure the file path is correct. Look at your error logs, `require_once` will report an error if the file doesn't exist. – ʰᵈˑ Oct 07 '15 at 09:14
  • it is correct, I check it few times... – pusty Oct 07 '15 at 09:15
  • Maybe your path isn't correct (even if you say so). Remember that if you have download your API at _yourwebsite.com/libraries/TeamSpeak3/TeamSpeak3.php_ and the page where you're trying to display it isn't _yourwebsite.com_ then the path should start with a **/** – naurel Nov 20 '15 at 16:49

1 Answers1

0

You forgot to add echo before each info so the code becomes :

require_once('libraries/TeamSpeak3/TeamSpeak3.php');
try
    {
      // connect to server, authenticate and grab info
      $ts3 = TeamSpeak3::factory("serverquery://query_admin:query_pass@host:10011/?server_port=9987");

      // show server as online
        echo $serverinfo[$j]['hostname'] = $ts3->virtualserver_name;
        echo $serverinfo[$j]['online'] = 'online';
        echo $serverinfo[$j]['players'] = $ts3->virtualserver_clientsonline;
        echo $serverinfo[$j]['max'] = $ts3->virtualserver_maxclients;

    }
    catch(Exception $e)
    {
      // grab errors and show server as offline
        echo $serverinfo[$j]['online'] = 'offline';
        echo $serverinfo[$j]['players'] = '-';
        echo $serverinfo[$j]['max'] = '-';
    }
Nic3500
  • 8,144
  • 10
  • 29
  • 40