Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Call to a member function on a non-object
Forum PHP.pl > Forum > Przedszkole
Recik
Witam, mam problem. Wyskakuje mi następujący błąd:

  1. Fatal error: Call to a member function on a non-object in ... on line 51


  1. <?php
  2. /*
  3.  * class_zajawki.php
  4.  * Created on 2008-12-26
  5.  *
  6.  * Autor: Mariusz Kropiwnicki
  7.  * Email: gsl@data.pl
  8.  */
  9.  
  10. require_once( dirname(__FILE__) . "/class_richtext.php");
  11.  
  12. class zajawki extends richtext {
  13.  
  14. var $table = 'podstrony';
  15. var $table_lang = 'podstrony_lang';
  16. var $table_relation = 'strona';
  17. var $max_art = 99;
  18. var $per_page = 5;
  19. var $template_file = 'stronaglowna.html';
  20. var $table_order = '';
  21.  
  22. var $zajawka_chars = 500;
  23.  
  24. function __construct() {
  25.  
  26. parent::__construct();
  27. }
  28.  
  29. function get() {
  30.  
  31. $this->template_initialize();
  32. $smarty = $this->template;
  33.  
  34. $smarty->assign('data', $this->zajawki());
  35.  
  36. return $smarty->fetch($this->template_file);
  37. }
  38.  
  39.  
  40. function zajawki( $extrawhere = "polecamy!= '0'") {
  41.  
  42. $sql = "select * from ". $this->table .
  43. " where ";
  44. if ( $extrawhere != '' ) $sql .= $extrawhere . " and ";
  45. $sql .= " publish != '0' " .
  46. " order by ";
  47.  
  48. if ( $this->table_order != '' ) $sql .= $this->table_order . ",";
  49. $sql .= "dmodify desc limit " . $this->max_art;
  50.  
  51. $data = $this->db->get_indexed_aarray ($sql);
  52. $listid = $this->utworz_listid( $sql );
  53.  
  54. if ( strlen($listid) > 0 ) {
  55.  
  56. $sql = "select * from ". $this->table_lang ." where ". $this->table_relation ." in ($listid) and
  57. publish != '0' and wersja='" . $this->lang . "'";
  58.  
  59. $tresci = $this->db->get_indexed_aarray ($sql);
  60.  
  61. while ( list ($k, $v) = each ($tresci) ) {
  62.  
  63. $tresc = 'Proszę uzupełnić';
  64. $nazwa = 'Proszę uzupełnić';
  65.  
  66. if ( array_key_exists('tresc', $v) ) $tresc = html_entity_decode($v['tresc']);
  67. if ( array_key_exists('nazwa', $v) ) $nazwa = html_entity_decode($v['nazwa']);
  68.  
  69. $images = $this->get_img_tags( $tresc );
  70. if ( count($images) > 0 ) $data[$v[$this->table_relation]]['zdjecie'] =
  71. // $this->imageurl ($ffoto,70,70);
  72. "cms/backend/image.php?width=70&height=70&path=" .
  73. urlencode($images[0]['src']);
  74.  
  75. $tresc = word_wrap(strip_tags($tresc), 64) ;
  76.  
  77. $data[$v[$this->table_relation]]['lnazwa'] = $nazwa;
  78. $data[$v[$this->table_relation]]['ltresc'] = $this->textLimit($tresc,$this->zajawka_chars);
  79. $data[$v[$this->table_relation]]['link'] =
  80. $this->seo_url($this->artykul_link_id( $v[$this->table_relation] ),
  81. $nazwa);
  82.  
  83. }
  84.  
  85. }
  86.  
  87. $i = 0;
  88. $res = array();
  89. reset($data);
  90. while ( list ($k, $v) = each ($data) ) {
  91.  
  92. $res[floor($i++/$this->per_page)][$k] = $v;
  93. }
  94.  
  95. $strona = $this->get_request('page', 0);
  96. return $res[$strona];
  97.  
  98.  
  99. }
  100.  
  101. function textLimit($string, $length, $replacer = '...')
  102. {
  103.  
  104.  
  105. $t = explode ( " ", $string);
  106. $res = '';
  107.  
  108. while ( list (,$v) = each ($t)) {
  109.  
  110. if ( trim($v) != '' ) {
  111. if ( strlen($res . " " . $v) > $length ) return $res . $replacer;
  112. $res .= " " . $v;
  113. }
  114. }
  115. return $string;
  116. }
  117.  
  118.  
  119. }
  120.  
  121.  
  122. ?>




Proszę o pomoc, z góry dziękuję!
mortus
Zmienna $this->db nie jest obiektem Twojej klasy obsługującej bazę danych. W ogóle nigdzie jej tutaj nie inicjujesz.
Recik
W takim razie co mam zrobić?
wookieb
Zadbać o to aby właściwość db byłą odpowiednim obiektem. Jak? Nie wiemy, nie znamy twojego systemu.
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.