Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php]non-object
Forum PHP.pl > Forum > Przedszkole
styx
Witam

Używałem kiedyś taką klasę(nie jest moja wzięta z neta), teraz odpalam i mam taki błąd. O co tu chodzi? php4/5

  1. <?php
  2. class ExtraGrid extends Structures_DataGrid
  3. {
  4. function ExtraGrid($limit = null, $page = null)
  5. {
  6. parent::Structures_DataGrid($limit, $page);
  7.  
  8.  $this->renderer->setTableAttribute('width', '100%'); //61 Line
  9.  $this->renderer->setTableAttribute('cellspacing', '0');
  10.  $this->renderer->setTableAttribute('cellpadding', '0');
  11.  $this->renderer->setTableAttribute('style', 'font-size:12px');
  12.  $this->renderer->setTableOddRowAttributes(array('style'=> 'background-color:#AAAAAA;'));
  13.  $this->renderer->setTableEvenRowAttributes(array('style'=> 'background-color:#CCCCCC;'));
  14.  
  15.  }
  16. }
  17. ?>

Błąd

Fatal error: Call to a member function setTableAttribute() on a non-object in /home/lordstyx/public_html/wp/klient.php on line 61
" title="Zobacz w manualu PHP" target="_manual



Pozdrawiam
misiek172
hmm wiesz to że masz PHP4/5 to nie znaczy ze działają 2 na raz smile.gif

to w roszerzeniu lub w .htaccess defniuje się jakim interpreterem ma być otwarty dany plik, PHP 5 czy 4

a jeśli chodzi o twój błąd to mi się wydaje że to jest źle smile.gif

$this->renderer->setTableAttribute

poniewaz on w tym momencie traktuje renderer jako obiekt, a renderer nim nie jest, ponieważ tym obiektem jest $this

tak wygląda składnia:

obiekt -> funkcja/zmienna/i.tym.podobne
styx
Dzięki misiek172 za odpowiedź, ale zauważ że ten skrypt działał poprawnie poprzednio, tylko nie pamiętam pod jakim php-em to było chyba 4-ka bo linuks wtedy był Red-hat 8.0.

Inna sprawa że ten skrypt jest w oparciu o inny skrypt który znalazłem w necie(też nie działa)

  1. <?php
  2. require 'Structures/DataGrid.php';
  3.  
  4. class myDataGrid extends Structures_DataGrid
  5. {
  6. function myDataGrid($limit = null, $page = null)
  7. {
  8. parent::Structures_DataGrid($limit, $page);
  9.  
  10. // Get the rendering layer instance
  11. $renderer =& $this->getRenderer();
  12.  
  13. // Define DataGrid Color Attributes
  14. $renderer->setTableEvenRowAttributes(array('class' => 'evenrow'));
  15. $renderer->setTableOddRowAttributes(array('class' => 'oddrow'));
  16.  
  17. // Define DataGrid Table Attributes
  18. $renderer->setTableAttribute('width', '100%');
  19. $renderer->setTableAttribute('cellspacing', '1');
  20. $renderer->setTableAttribute('cellpadding', '4');
  21. $renderer->setTableAttribute('class', 'datagrid');
  22.  
  23. // Set sorting icons
  24. $renderer->sortIconASC = '&uarr;';
  25. $renderer->sortIconDESC = '&darr;';
  26. }
  27. }
  28. ?>


nie wiem od czego to zależy
misiek172
te klasy co piszesz są napewno w PHP4, ponieważ przy PHP5 jeszcze definiuje sie rodzaje funkcji, czy public, protected, private i takie tam

stwórz sobie plik .htaccess w folderze z tym plikiem
i w .htaccess wpisz:

:Location /*.php
Use php4
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.