Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Undefined index
TheBill
post 28.04.2014, 21:20:44
Post #1





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 28.04.2014

Ostrzeżenie: (0%)
-----


Witam
Na wstępie chciałbym zaznaczyć, że żaden ze mnie programista.
Także proszę wszystko bardzo "łopatologicznie"

Na chwilę obecną mam problem z dobraniem się do pewnych danych:

  1. $summoner = $nicknamelist;
  2. $url = "http://prod.api.pvp.net/api/lol/eune/v1.4/summoner/by-name/" . $summoner . "?api_key=" . $key;
  3. $JSON = file_get_contents($url);
  4. $data = json_decode($JSON, true);
  5. $summonerId=$data["id"];
  6. //var_dump($data); <a href="http://pastebin.com/fNqK2K86" target="_blank">http://pastebin.com/fNqK2K86</a>
  7. // print_r($data); <a href="http://pastebin.com/qg3iXDNX" target="_blank">http://pastebin.com/qg3iXDNX</a>
  8. $urlLeague = "http://prod.api.pvp.net/api/lol/na/v2.3/league/by-summoner/" . $summonerId . "?api_key=" . $key;
  9. $JSONLeague = file_get_contents($urlLeague);
  10. $lgData=json_decode($JSONLeague,true);
  11.  

Wyskakuje mi powiadomienie
PHP Notice: Undefined index: id
Powiedzcie mi proszę co robię źle?

Go to the top of the page
+Quote Post
ZaXaZ
post 28.04.2014, 21:36:06
Post #2





Grupa: Zarejestrowani
Postów: 285
Pomógł: 18
Dołączył: 30.01.2014
Skąd: <?=$_GET['city']?>

Ostrzeżenie: (0%)
-----


  1. $summonerId=$data["id"];
  2. zamień na:
  3. foreach($data[] as $summonerId) $summonerId['id']."\r\n"; /*powinno wyświetlić wszystkich graczy ale głowy nie daję*/
  4. #lub jak chcesz jednego to
  5. $summornerId=$data['nickOsoby']['id'];


Ten post edytował ZaXaZ 28.04.2014, 21:53:54


--------------------
Go to the top of the page
+Quote Post
TheBill
post 28.04.2014, 22:08:48
Post #3





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 28.04.2014

Ostrzeżenie: (0%)
-----


Zależałoby mi właśnie na wszystkich graczach bo lista jest zmienna.
Gdy zamienie:
  1. $summonerId=$data["id"]; na foreach($data[] as $summonerId) $summonerId['id']."\r\n";

niestety wyskakuje błąd:
PHP Fatal error: Cannot use []
Docelowo chciałbym uzyskać efekt gracz:liga.
Go to the top of the page
+Quote Post
Turson
post 28.04.2014, 22:10:11
Post #4





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


nie $data[] a $data

print_r($data);
prawdę ci powie

Ten post edytował Turson 28.04.2014, 22:10:46
Go to the top of the page
+Quote Post
TheBill
post 3.05.2014, 02:49:15
Post #5





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 28.04.2014

Ostrzeżenie: (0%)
-----


Dziękuje wszystkim za sugestie.
Temat do zamknięcia.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 13.06.2025 - 11:24