Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Problem z klasą - błąd
Forum PHP.pl > Forum > Przedszkole
Arsanael
napisalem cos takiego:

PLIK CLASS.PHP: (wycinek)

  1. class Travel
  2. {
  3. var $id;
  4. var $to_x;
  5. var $to_y;
  6. var $speed;
  7. var $type;
  8. var $gobliny;
  9. var $me;
  10. var $player_id;
  11. var $end_s;
  12. var $end_m;
  13. var $end_h;
  14. var $koniec_podrozy;
  15.  
  16.  
  17.  
  18. function Travel($pID)
  19. {
  20. global $db;
  21. $statis = $db -> Execute("SELECT * FROM travel WHERE player_id=".$pID);
  22. $this -> id = $statis -> fields['id'];
  23. $this -> to_x = $statis -> fields['to_x'];
  24. $this -> to_y = $statis -> fields['to_y'];
  25. $this -> speed = $statis -> fields['speed'];
  26. $this -> type = $statis -> fields['type'];
  27. $this -> gobliny = $statis -> fields['gobliny'];
  28. $this -> me = $statis -> fields['me'];
  29. $this -> player_id = $statis -> fields['player_id'];
  30. $this -> end_s = $statis -> fields['end_s'];
  31. $this -> end_m = $statis -> fields['end_m'];
  32. $this -> end_h = $statis -> fields['end_h'];
  33. $this -> koniec_podrozy = $statis -> fields['koniec_podrozy'];
  34. $statis -> Close();
  35. }
  36.  
  37.  
  38.  
  39. function statis($statis)
  40. {
  41. $arrstatis = array();
  42. foreach ($statis as $valuee)
  43. {
  44. $arrstatis[$valuee] = $this -> $valuee;
  45. }
  46. return $arrstatis;
  47. }
  48.  
  49. }



plik CLASS.PHP includuje do innego pliku i daje:

  1. $travel = new Travel($statis -> fields['id']);



nie mam pojęcia co jest źle ale pojawia mi sie błąd:

Cytat
Fatal error: Call to a member function Close() on a non-object in /home/accounts_a/arsanael/public_html/eportal/class.php on line 269



jeszcze wspomne że 269 linijka to ta:

  1. $statis -> Close();



nie mam pojecia co jest źle ;/ prosze o pomoc
erix
Sprawdź, czy statis jest faktycznie tym obiektem, którego potrzebujesz...
zend
Raczej sprawdź czy $static wogóle jest obiektem, oraz czy ma metodę Close, stosuj też public/private/protected zamiast var
  1. if(!is_object($static)) echo 'to nie obiekt';
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.