Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Błąd Fatal error: Cannot use string offset as an array in
-macis-
post
Post #1





Goście







Mam dwa błędy, da się coś z nimi zrobic ? (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Warning: Invalid argument supplied for foreach() in .... on line 16

Fatal error: Cannot use string offset as an array in ... on line 27


  1. <?php
  2. include('config.php');
  3.  
  4. if(isset($_GET['name'])){
  5. $name=$_GET['name'];
  6. }else{
  7. };
  8. if(isset($_GET['artist'])){
  9. $artist=$_GET['artist'];
  10. }else{
  11. };
  12. $content=object2array(simplexml_load_file('http://ws.audioscrobbler.com/1.0/track/'.$artist.'/'.$name.'/similar.xml'));
  13. ?><h1>Podobne</h1>
  14. <?foreach($content['track'] as $value){
  15. ?>
  16. <a href="artist.php?name=<?=urlencode($value["artist"]["name"])?>"><?=$value["artist"]["name"]?></a>-<a href="track.php?name=<?=urlencode($value['name'])?>&artist=<?=urlencode($value["artist"]["name"])?>"><?=$value['name']?></a><?=$value["match"]?><br>
  17. <?
  18. };
  19. ?>
  20. <h1>Najwięksi</h1>
  21. <?
  22. $content=object2array(simplexml_load_file('http://ws.audioscrobbler.com/1.0/track/'.$artist.'/'.$name.'/fans.xml'));
  23. foreach($content['user'] as $value){
  24. ?>
  25. <?=$value["@attributes"]['username']?>(<?=$value['weight']?>)<Br><?
  26. };
  27. ?>
  28. <h1>Najwięksi</h1>
  29. <?
  30. $content=object2array(simplexml_load_file('http://ws.audioscrobbler.com/1.0/track/'.$artist.'/'.$name.'/toptags.xml'));
  31. foreach($content['tag'] as $value){
  32. ?>
  33. <a href="tag.php?name=<?=urlencode($value['name'])?>"><?=$value['name']?></a><br><?
  34. };
Go to the top of the page
+Quote Post
Sabistik
post
Post #2


Administrator wortalu


Grupa: Przyjaciele php.pl
Postów: 960
Pomógł: 39
Dołączył: 21.10.2003
Skąd: Kraków

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


Musisz debugować skrypt i sprawdzać co masz w tych zmiennych przy których występują błędy.
Widzę że to ma pobierać dane z audioscrobblera - sprawdź czy wymaganej funkcjonalności nie znajdziesz w Zend_Service_Audioscrobbler - bo z jego pomocą wszystko staje się łatwiejsze (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 23.08.2025 - 23:24