Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Smarty a w tym classa (błąd)
Forum PHP.pl > Forum > Przedszkole
Zmorcia
  1. <?
  2. class saveConcurs
  3. {
  4. public function saveArrays()
  5. {
  6. $this->saveName = $_POST['saveName'];
  7. $this->saveEmail = $_POST['saveEmail'];
  8. $this->savePhone = $_POST['savePhone'];
  9. $this->saveCode = $_POST['saveCode'];
  10.  
  11. smarty::assign('smartyName', $this->saveName);
  12. smarty::assign('smartyEmail', $this->saveEmail);
  13. smarty::assign('smartyPhone', $this->savePhone);
  14. smarty::assign('smartyCode', $this->saveCode);
  15. smarty::display('save.tpl');
  16. }
  17. }
  18.  
  19. $save = new saveConcurs;
  20. $save -> saveArrays();
  21. ?>


Popatrzcie jaki mam błąd:

Fatal error: Call to undefined method saveConcurs::fetch() in /home/accounts_c/chill/public_html/sms/smarty/Smarty.class.php on line 1105
phpion
Cytat(Zmorcia @ 18.08.2009, 11:45:37 ) *
Popatrzcie jaki mam błąd:

Oł jea, zaj***sty błąd! yahoo.gif

PS: Gdzieś dalej wywołujesz metodę fetch() na obiekcie klasy saveConcurs, która to tej metody nie posiada. Kod, który wkleiłeś nie powoduje tego błędu.
Zmorcia
Jak wywale:
  1. smarty::assign('smartyName', $this->saveName);
  2. smarty::assign('smartyEmail', $this->saveEmail);
  3. smarty::assign('smartyPhone', $this->savePhone);
  4. smarty::assign('smartyCode', $this->saveCode);
  5. smarty::display('save.tpl');


to wszystko działa, lecz po wlączeniu smartów jest ten error.
wookieb
A pokazesz save.tpl ?

Ściągnij najnowsze smarty i zobacz czy też będzie błąd.

BTW wydawało mi się, że smarty nie jest statyczne.
Zmorcia
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html>
  4. <head>
  5. <title>Zapisy do konkursu</title>
  6. <meta name="keywords" content="traaaa" />
  7. <meta name="description" content="traaaa" />
  8. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
  9. <link href="{$url}/templates/{$template}/styles/style-1.css" rel="stylesheet" type="text/css" media="screen" />
  10. </head>
  11. <body>
  12. <div id="webContainer">
  13. <div id="webLogo">Zapisy do konkursu.</div>
  14. <div id="webContent">
  15. <form method="post" action="">
  16. <label for="saveName" id="webLabel">Twoje imie:</label> <input type="text" name="saveName"><br />
  17. <label for="saveEmail" id="webLabel">Twój email:</label> <input type="text" name="saveEmail"><br />
  18. <label for="savePhone" id="webLabel">Numer telefonu:</label> <input type="text" name="savePhone"><br />
  19. <label for="saveCode" id="webLabel">Kod z SMS:</label> <input type="text" name="saveCode"><br />
  20. <input type="submit" value="zapisz sie">
  21. </form>
  22. </div>
  23. </div>
  24. </body>
  25. </html>


200 post <piwo>


Cytat(wookieb @ 18.08.2009, 11:57:00 ) *
A pokazesz save.tpl ?

Ściągnij najnowsze smarty i zobacz czy też będzie błąd.

BTW wydawało mi się, że smarty nie jest statyczne.


Mam najnowsze smarty.
wookieb
Na pewno nie masz albo coś źle zrobiłeś bo w najnowyszm smarty w linijce od 1000 do 1010 nie ma wywołania metody fetch. Ściągnij jeszcze raz i sprawdź.
Zmorcia
no, ok winksmiley.jpg

Nadaj to: Fatal error: Call to undefined method saveConcurs::fetch() in /home/accounts_c/chill/public_html/sms/smarty/Smarty.class.php on line 1106
wookieb
Strict Standards: Non-static method Smarty::display() should not be called statically, assuming $this from incompatible context in E:\Apache2\htdocs\smarty_test\index.php on line 23

Czyli dobrze myślałem, że smarty nie jest statyczne. Musisz do swojego obiektu przekazać egzemplarz obiektu smarty i na nim wywoływać metody.

Weź popraw nazwę swojej klasy bo to poniżej poziomu żałości http://www.getionary.pl/search?query=konku...l_ang&ln=pl

@Phpion - następnym razem uważaj co mówisz.
Zmorcia
Cytat(wookieb @ 18.08.2009, 12:23:04 ) *
Strict Standards: Non-static method Smarty::display() should not be called statically, assuming $this from incompatible context in E:\Apache2\htdocs\smarty_test\index.php on line 23

Czyli dobrze myślałem, że smarty nie jest statyczne. Musisz do swojego obiektu przekazać egzemplarz obiektu smarty i na nim wywoływać metody.

Weź popraw nazwę swojej klasy bo to poniżej poziomu żałości http://www.getionary.pl/search?query=konku...l_ang&ln=pl

@Phpion - następnym razem uważaj co mówisz.




concurs = zgadza się (w nim głowna classa)


napisz mi jak ma wygladac cala classa, z tym egzemplazem.
wookieb
To zobacz jak jest po angielsku "Konkurs".

Przekazać $smarty do funkcji nie umiesz? To pora się nauczyć
Zmorcia
No to mnie naucz winksmiley.jpg

bede wdzięczny winksmiley.jpg
Zmorcia
Nic z tego Manuala nie zrozumiałem ;/

Dobra, mam winksmiley.jpg thx

  1. <?
  2. class saveConcurs
  3. {
  4. public function saveArrays($smarty)
  5. {
  6. $this->saveName = $_POST['saveName'];
  7. $this->saveEmail = $_POST['saveEmail'];
  8. $this->savePhone = $_POST['savePhone'];
  9. $this->saveCode = $_POST['saveCode'];
  10.  
  11. $smarty->assign('smartyName', $this->saveName);
  12. $smarty->assign('smartyEmail', $this->saveEmail);
  13. $smarty->assign('smartyPhone', $this->savePhone);
  14. $smarty->assign('smartyCode', $this->saveCode);
  15. $smarty->display('save.tpl');
  16.  
  17. }
  18. }
  19.  
  20. $save = new saveConcurs;
  21. $save -> saveArrays($smarty);
  22. ?>
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.