Problemy PHP

Założony przez  Kacper Wojciechowski.

Witam, mam problem z kodem PHP, jest to problem nie związany z skryptem forum. Mój kod:

<?php
echo "<td style=\"text-align: center;"><a href=\'#elTabelaSamp_menu\' id=\'elTabelaSamp\' data-ipsMenu>x/200 <i class=\"fa fa-caret-down"></i></a>";
echo "<ul id=\'elTabelaSamp_menu\' class=\'ipsMenu ipsHide\'>";
echo "<li class=\'ipsMenu_title\'>Lista Graczy Online</li>";
require "applications/panel/sources/SampQueryAPI.php";
$query = new SampQueryAPI('
80.72.47.182', '3644');

if($query->isOnline())
{
   $aInformation = $query->getInfo();
   $aServerRules = $query->getRules();
  
   $aPlayers = $query->getDetailedPlayers();
      
   if(!is_array($aPlayers) || count($aPlayers) == 0)
   {
       echo '
<li class=\'ipsMenu_item\' data-ipsMenuValue=\'itemID\'><a href=\'#\'>Brak graczy na serwerze! :(</a></li>';
 
  }
 
  else
 
  {
 
      foreach($aPlayers as $sValue)
 
      {
 
                   echo "<li class=\'ipsMenu_item\' data-ipsMenuValue=\'itemID\'><a href=\'#\' data-ipsDialog data-ipsDialog-url=\'applications/panel/sources/statygraczapopup.php\'>".htmlentities($sValue['nickname'])."</a></li>";
 
      }
 
  }
}
else
{
 
  echo '<li class=\'ipsMenu_item\' data-ipsMenuValue=\'itemID\'><a href=\'#\'>Brak graczy na serwerze! :(</a></li>';
}
echo 
"<li class=\'ipsMenu_item\' data-ipsMenuValue=\'itemID\'><a href=\'#\' data-ipsDialog data-ipsDialog-url=\'applications/panel/sources/statygraczapopup.php\'>Tu będzie gracz :)</a></li>";
echo 
"</ul>";
echo 
"</td>";
?>
Problem w tym, że się wyświetla pusta strona, proszę nie zwracać na zwarte w kodzie klasy. Chcę wyświetlić graczy online.

http://psr-serv.pl/t.php
Masz namieszane z " i '`'. Przecież to widać po kolorze kodu.
echo "<td style=\"text-align: center;"><a href=\'#elTabelaSamp_menu\' 
Proponują przyjąć taki zapis
echo '<td style="text-align: center;"><a href="#elTabelaSamp_menu" id="elTabelaSamp" data-ipsMenu>x/200 <i class="fa fa-caret-down"></i></a>'

I możesz sobie włączyć wyświetlanie błędów na czas tworzenia skryptu http://stackoverflow.com/questions/10534...to-display
Nie wiedziałem, że to jest jakaś różnica :P

Teraz PHP działa ale dane się nie zwracają

<?php
require "applications/panel/sources/SampQueryAPI.php";
$query = new SampQueryAPI("80.72.47.182""3644");
echo 
"<div class=\"ipsfocusBox\">";
echo 
"<h2 class=\"ipsType_sectionTitle ipsType_reset ipsType_blendLinks cForumTitle\">Lista serwerów</h2>";
echo 
"<div class=\"ipsfocusBackground\">";
echo 
"<table class=\"ipsTable ipsTable_responsive ipsTable_zebra ipsBox\">";
echo 
"<thead><tr>";
echo 
"<th style=\"text-align: center;\">Gra</th>";
echo 
"<th style=\"text-align: center;\">Nazwa</th>";
echo 
"<th style=\"text-align: center;\">Adres</th>";
echo 
"<th style=\"text-align: center;\">Gracze</th>";
echo 
"<th style=\"text-align: center;\">Menu</th>";
echo 
"</tr></thead>";
echo 
"<tbody><tr>";
echo 
"<td style=\"text-align: center;\"><img src=\"http://i.imgur.com/Jlcx90r.png\" style=\"border-radius: 4px;\"></td>";
echo 
"<td style=\"text-align: center;\">".htmlentities($aInformation['hostname'])."</td>";
echo 
"<td style=\"text-align: center;\">Już Niedługo!</td>";
echo 
"<td style=\"text-align: center;\"><a href=\"#elTabelaSamp_menu\" id=\"elTabelaSamp\" data-ipsMenu> ".$aInformation['players']." / ".$aInformation['maxplayers']." <i class=\"fa fa-caret-down\"></i></a>";
echo 
"<ul id=\"elTabelaSamp_menu\" class=\"ipsMenu ipsHide\">";
echo 
"<li class=\"ipsMenu_title\">Lista Graczy Online</li>";

if(
$query->isOnline())
{
 
  $aInformation $query->getInfo();
 
  $aServerRules $query->getRules();
 
 
   $aPlayers 
$query->getDetailedPlayers();
 
     
   
if(!is_array($aPlayers) || count($aPlayers) == 0)
 
  {
 
      echo "<li class=\"ipsMenu_item\" data-ipsMenuValue=\"itemID\"><a href=\"#\">Brak graczy na serwerze! :(</a></li>";
 
  }
 
  else
 
  {
 
      foreach($aPlayers as $sValue)
 
      {
 
                   echo "<li class=\"ipsMenu_item\" data-ipsMenuValue=\"itemID\"><a href=\"#\" data-ipsDialog data-ipsDialog-url=\"applications/panel/sources/statygraczapopup.php\">".htmlentities($sValue['nickname'])."</a></li>";
 
      }
 
  }
}
else
{
 
  echo "<li class=\"ipsMenu_item\" data-ipsMenuValue=\'itemID\'><a>Brak graczy na serwerze! :(</a></li>";
}
echo 
"</ul>";
echo 
"</td>";
echo 
"<td style=\"text-align: center;\">";
echo 
"<a href=\"http://files.sa-mp.com/sa-mp-0.3.7-install.exe\" data-ipsdialog-title=\"Pobierz demo\" class=\"ipsButton ipsButton_primary ipsButton_verySmall\"><i class=\"fa fa-download\"></i> SAMP 0.3.7</a>";
echo 
"<a href=\"samp://ip\" data-ipsdialog-title=\"Połącz z serwerem\" class=\"ipsButton ipsButton_primary ipsButton_verySmall\"><i class=\"fa fa-play-circle-o\"></i> Połącz</a>";
echo 
"</td>";
echo 
"</tr></tbody>";
echo 
"</table></div></div>";
?>
Dodaj wyświetlanie błędów, oraz pokaż tą stronę online.
Dodatkowo zamiast robić wszystko w echo można zrobić tak
<?php
require "applications/panel/sources/SampQueryAPI.php";
$query = new SampQueryAPI("80.72.47.182""3644");
?>
<div class="ipsfocusBox">
<h2 class="ipsType_sectionTitle ipsType_reset ipsType_blendLinks cForumTitle">Lista serwerów</h2>
<div class="ipsfocusBackground">
<table class="ipsTable ipsTable_responsive ipsTable_zebra ipsBox">
<thead><tr>
<?php
// inny kod php
?>
<!-- znowu html --> 
jak to
htmlentities($aInformation['hostname'])
moglo sie znalesc przed
$aInformation = $query->getInfo();

podaj jakis adres gdzie to odpalasz i daj plik SampQueryAPI.php w zalaczniku

nawet nazw klas nie chce sie zmienic ehh..
Wiem, że jest lepiej nie robić wszystkiego w echo ale używam skryptu IPS 4 (Piszę tu w HydePark bo support IPS jest szybki niczym burza xd) i tam jak dodaję blok to on już sam tworzy <?php i ?>. Włączyłem wyświetlanie błędów i mam:

Notice: Undefined variable: iError in /home/samppsrd/domains/psr-serv.pl/public_html/applications/panel/sources/SampQueryAPI.php on line 42

Notice: Undefined variable: sError in /home/samppsrd/domains/psr-serv.pl/public_html/applications/panel/sources/SampQueryAPI.php on line 42

Warning: fsockopen() has been disabled for security reasons in /home/samppsrd/domains/psr-serv.pl/public_html/applications/panel/sources/SampQueryAPI.php on line 42

http://psr-serv.pl/t.php


  SampQueryAPI.php (Rozmiar: 7,35 KB / Pobrań: 277)
fsockopen() has been disabled for security reasons
Dobra działa, wielkie dzięki :) Będę tu pisał z kolejnymi moimi problemami
<?php
require "applications/panel/sources/SampQueryAPI.php";
$query = new SampQueryAPI("80.72.47.182""3644");
   
$aInformation $query->getInfo();
   
$aServerRules $query->getRules();
  
   
$aPlayers $query->getDetailedPlayers();
   
echo 
"<div class=\"ipsfocusBox\">";
echo 
"<h2 class=\"ipsType_sectionTitle ipsType_reset ipsType_blendLinks cForumTitle\">Lista serwer?h2>";
echo 
"<div class=\"ipsfocusBackground\">";
echo 
"<table class=\"ipsTable ipsTable_responsive ipsTable_zebra ipsBox\">";
echo 
"<thead><tr>";
echo 
"<th style=\"text-align: center;\">Gra</th>";
echo 
"<th style=\"text-align: center;\">Nazwa</th>";
echo 
"<th style=\"text-align: center;\">Adres</th>";
echo 
"<th style=\"text-align: center;\">Gracze</th>";
echo 
"<th style=\"text-align: center;\">Menu</th>";
echo 
"</tr></thead>";
echo 
"<tbody><tr>";
echo 
"<td style=\"text-align: center;\"><img src=\"http://i.imgur.com/Jlcx90r.png\" style=\"border-radius: 4px;\"></td>";
echo 
"<td style=\"text-align: center;\">".htmlentities($aInformation['hostname'])."</td>";
echo 
"<td style=\"text-align: center;\">JuߠNiedԵgo!</td>";
echo 
"<td style=\"text-align: center;\"><a href=\"#elTabelaSamp_menu\" id=\"elTabelaSamp\" data-ipsMenu> ".$aInformation['players']." / ".$aInformation['maxplayers']." <i class=\"fa fa-caret-down\"></i></a>";
echo 
"<ul id=\"elTabelaSamp_menu\" class=\"ipsMenu ipsHide\">";
echo 
"<li class=\"ipsMenu_title\">Lista Graczy Online</li>";

if(
$query->isOnline())
{
      
   if(!
is_array($aPlayers) || count($aPlayers) == 0)
   {
       echo 
"<li class=\"ipsMenu_item\" data-ipsMenuValue=\"itemID\"><a href=\"#\">Brak graczy na serwerze! :(</a></li>";
   }
   else
   {
       foreach(
$aPlayers as $sValue)
       {
                    echo 
"<li class=\"ipsMenu_item\" data-ipsMenuValue=\"itemID\"><a href=\"#\" data-ipsDialog data-ipsDialog-url=\"applications/panel/sources/statygraczapopup.php\">".htmlentities($sValue['nickname'])."</a></li>";
       }
   }
}
else
{
   echo 
"<li class=\"ipsMenu_item\" data-ipsMenuValue=\'itemID\'><a>Brak graczy na serwerze! :(</a></li>";
}
echo 
"</ul>";
echo 
"</td>";
echo 
"<td style=\"text-align: center;\">";
echo 
"<a href=\"http://files.sa-mp.com/sa-mp-0.3.7-install.exe\" data-ipsdialog-title=\"Pobierz demo\" class=\"ipsButton ipsButton_primary ipsButton_verySmall\"><i class=\"fa fa-download\"></i> SAMP 0.3.7</a>";
echo 
"<a href=\"samp://ip\" data-ipsdialog-title=\"Poӹcz z serwerem\" class=\"ipsButton ipsButton_primary ipsButton_verySmall\"><i class=\"fa fa-play-circle-o\"></i> Poӹcz</a>";
echo 
"</td>";
echo 
"</tr></tbody>";
echo 
"</table></div></div>";
?>

Łączysz to z MyBB? (jako podstrona forum MyBB?)
(31.01.2016, 20:59)GiboneKPL napisał(a): Łączysz to z MyBB? (jako podstrona forum MyBB?)
Nie

Potrzebuję pobrać treść z zmiennej z tego wyniku:
echo "<li class=\"ipsMenu_item\" data-ipsMenuValue=\"itemID\"><a href=\"#\" name=\"player_name\" data-ipsDialog data-ipsDialog-url=\"applications/panel/sources/statygraczapopup.php\" >".htmlentities($sValue["nickname"])."</a></li>";

Gdzie name=\"player_name\" nie pobiera nicku. Jak jest np. na serwerze gracz z nickiem X3nO to żeby pobrało player_name=X3nO

A funkcji method=get nie wiem jak w tym przypadku użyć

PS. Nie warnujcie za double post ale edit na telu mi crashuje przegladarke
<?php
require "SampQueryAPI.php";
$query = new SampQueryAPI("80.72.47.182""3644");
   
$aInformation $query->getInfo();
   
$aServerRules $query->getRules();
  
   
$aPlayers $query->getDetailedPlayers();
   if(
$query->isOnline())
{
      
   if(!
is_array($aPlayers) || count($aPlayers) == 0)
   {
      
$players "<li class=\"ipsMenu_item\" data-ipsMenuValue=\"itemID\"><a href=\"#\">Brak graczy na serwerze! :(</a></li>";
   }
   else
   {
       foreach(
$aPlayers as $sValue)
       {
         
$players "<li class=\"ipsMenu_item\" data-ipsMenuValue=\"itemID\"><a href=\"#\" data-ipsDialog data-ipsDialog-url=\"applications/panel/sources/statygraczapopup.php\">".htmlentities($sValue['nickname'])."</a></li>";
       }
   }
}
else
{
   
$players "<li class=\"ipsMenu_item\" data-ipsMenuValue=\'itemID\'><a>Brak graczy na serwerze! :(</a></li>";
}
echo 
"<div class=\"ipsfocusBox\">";
echo 
"<h2 class=\"ipsType_sectionTitle ipsType_reset ipsType_blendLinks cForumTitle\">Lista serwer?h2>";
echo 
"<div class=\"ipsfocusBackground\">";
echo 
"<table class=\"ipsTable ipsTable_responsive ipsTable_zebra ipsBox\">";
echo 
"<thead><tr>";
echo 
"<th style=\"text-align: center;\">Gra</th>";
echo 
"<th style=\"text-align: center;\">Nazwa</th>";
echo 
"<th style=\"text-align: center;\">Adres</th>";
echo 
"<th style=\"text-align: center;\">Gracze</th>";
echo 
"<th style=\"text-align: center;\">Menu</th>";
echo 
"</tr></thead>";
echo 
"<tbody><tr>";
echo 
"<td style=\"text-align: center;\"><img src=\"http://i.imgur.com/Jlcx90r.png\" style=\"border-radius: 4px;\"></td>";
echo 
"<td style=\"text-align: center;\">".htmlentities($aInformation['hostname'])."</td>";
echo 
"<td style=\"text-align: center;\">Ju?Nied?go!</td>";
echo 
"<td style=\"text-align: center;\"><a href=\"#elTabelaSamp_menu\" id=\"elTabelaSamp\" data-ipsMenu> ".$aInformation['players']." / ".$aInformation['maxplayers']." <i class=\"fa fa-caret-down\"></i></a>";
echo 
"<ul id=\"elTabelaSamp_menu\" class=\"ipsMenu ipsHide\">";
echo 
"<li class=\"ipsMenu_title\">Lista Graczy Online</li>";
echo 
$players;
echo 
"</ul>";
echo 
"</td>";
echo 
"<td style=\"text-align: center;\">";
echo 
"<a href=\"http://files.sa-mp.com/sa-mp-0.3.7-install.exe\" data-ipsdialog-title=\"Pobierz demo\" class=\"ipsButton ipsButton_primary ipsButton_verySmall\"><i class=\"fa fa-download\"></i> SAMP 0.3.7</a>";
echo 
"<a href=\"samp://ip\" data-ipsdialog-title=\"Po?cz z serwerem\" class=\"ipsButton ipsButton_primary ipsButton_verySmall\"><i class=\"fa fa-play-circle-o\"></i> Po?cz</a>";
echo 
"</td>";
echo 
"</tr></tbody>";
echo 
"</table></div></div>";
?>
(01.02.2016, 14:43)GiboneKPL napisał(a):
<?php
require "SampQueryAPI.php";
$query = new SampQueryAPI("80.72.47.182""3644");
   
$aInformation $query->getInfo();
   
$aServerRules $query->getRules();
  
   
$aPlayers $query->getDetailedPlayers();
   if(
$query->isOnline())
{
      
   if(!
is_array($aPlayers) || count($aPlayers) == 0)
   {
      
$players "<li class=\"ipsMenu_item\" data-ipsMenuValue=\"itemID\"><a href=\"#\">Brak graczy na serwerze! :(</a></li>";
   }
   else
   {
       foreach(
$aPlayers as $sValue)
       {
         
$players "<li class=\"ipsMenu_item\" data-ipsMenuValue=\"itemID\"><a href=\"#\" data-ipsDialog data-ipsDialog-url=\"applications/panel/sources/statygraczapopup.php\">".htmlentities($sValue['nickname'])."</a></li>";
       }
   }
}
else
{
   
$players "<li class=\"ipsMenu_item\" data-ipsMenuValue=\'itemID\'><a>Brak graczy na serwerze! :(</a></li>";
}
echo 
"<div class=\"ipsfocusBox\">";
echo 
"<h2 class=\"ipsType_sectionTitle ipsType_reset ipsType_blendLinks cForumTitle\">Lista serwer?h2>";
echo 
"<div class=\"ipsfocusBackground\">";
echo 
"<table class=\"ipsTable ipsTable_responsive ipsTable_zebra ipsBox\">";
echo 
"<thead><tr>";
echo 
"<th style=\"text-align: center;\">Gra</th>";
echo 
"<th style=\"text-align: center;\">Nazwa</th>";
echo 
"<th style=\"text-align: center;\">Adres</th>";
echo 
"<th style=\"text-align: center;\">Gracze</th>";
echo 
"<th style=\"text-align: center;\">Menu</th>";
echo 
"</tr></thead>";
echo 
"<tbody><tr>";
echo 
"<td style=\"text-align: center;\"><img src=\"http://i.imgur.com/Jlcx90r.png\" style=\"border-radius: 4px;\"></td>";
echo 
"<td style=\"text-align: center;\">".htmlentities($aInformation['hostname'])."</td>";
echo 
"<td style=\"text-align: center;\">Ju?Nied?go!</td>";
echo 
"<td style=\"text-align: center;\"><a href=\"#elTabelaSamp_menu\" id=\"elTabelaSamp\" data-ipsMenu> ".$aInformation['players']." / ".$aInformation['maxplayers']." <i class=\"fa fa-caret-down\"></i></a>";
echo 
"<ul id=\"elTabelaSamp_menu\" class=\"ipsMenu ipsHide\">";
echo 
"<li class=\"ipsMenu_title\">Lista Graczy Online</li>";
echo 
$players;
echo 
"</ul>";
echo 
"</td>";
echo 
"<td style=\"text-align: center;\">";
echo 
"<a href=\"http://files.sa-mp.com/sa-mp-0.3.7-install.exe\" data-ipsdialog-title=\"Pobierz demo\" class=\"ipsButton ipsButton_primary ipsButton_verySmall\"><i class=\"fa fa-download\"></i> SAMP 0.3.7</a>";
echo 
"<a href=\"samp://ip\" data-ipsdialog-title=\"Po?cz z serwerem\" class=\"ipsButton ipsButton_primary ipsButton_verySmall\"><i class=\"fa fa-play-circle-o\"></i> Po?cz</a>";
echo 
"</td>";
echo 
"</tr></tbody>";
echo 
"</table></div></div>";
?>
Nie o to mi chodziło

To jest mój kod tabeli:
http://pastebin.com/DsT3HnrB

Pliik statygraczapopup.php (Do niego chcę wysłać nick):
http://pastebin.com/VL82RSa1

Ale nie wiem jak z .htmlentities($sValue["nickname"]). zrobić _GET do statygraczapopup.php
Żeby było GET musi być FORM (przynajmniej tak mnie uczono). Nie próbowałeś require_once?
Nie za bardzo mogę użyć tej funkcji w tym przypadku :/
To co Ty chcesz zrobić? Statystyki gracza w popupie wyświetlić czy jako osobną stronę?



Użytkownicy przeglądający ten wątek:

1 gości