Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Problem z metoda klasy
hondek
post 12.06.2009, 15:20:02
Post #1





Grupa: Zarejestrowani
Postów: 355
Pomógł: 50
Dołączył: 20.08.2007
Skąd: Częstochowa

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


Witam!
Mam klase eventsManager, a w niej metode getMany, ktora zwraca mi newsy...
  1. <?php
  2. function getMany($startFrom, $howMany, $what) {
  3.        switch($what) {
  4.            case 'news':
  5.                $res = "SELECT * FROM events ORDER BY eventDate DESC LIMIT $startFrom,$howMany";
  6.                break;
  7.            case 'after':
  8.                $res = "SELECT * FROM events WHERE eventDate < curdate() ORDER BY eventDate DESC LIMIT $startFrom,$howMany";
  9.                break;
  10.        }
  11.        $args = array();
  12.        $res = mysql_query($res);
  13.        while ($events = mysql_fetch_assoc($res)) {
  14.            $args[] = new event($events);
  15.        }
  16.        return $args;
  17.    }
  18. ?>

moj problem polega na tym, ze jezeli raz wywołam funkcje getMany to za nastepnym razem mysql wywala blad :
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/desktop/public_html/classes/news.class.php on line 42


np:
  1. <div class="shortNews">
  2.                <?$event = new eventsManager;
  3.                foreach( $event->getMany(0,5, 'after') as $e ) {
  4.                    ?>
  5.                    <p><?=showDate($e->get__('eventDate'))?> <?=showClub($e->get__('club'))?> <?=$e->get__('title')?></p>
  6.                    <?
  7.                }
  8.                ?>
  9.            </div>
  10.            <div class="shortAfter">
  11.                <?
  12.                foreach( $event->getMany(0,5, 'after') as $e ) {
  13.                    ?>
  14.                    <p><?=showDate($e->get__('eventDate'))?> <?=showClub($e->get__('club'))?> <?=$e->get__('title')?></p>
  15.                    <?
  16.                }?>
  17.            </div>

daje:
30 04 2009 Klub Title


11 04 2009 Klub Title

08 04 2009 Klub Title


06 04 2009 Klub Title

16 04 1993 Klub Title


Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/desktop/public_html/classes/news.class.php on line 42

Mam nadzieje ze w miare zrozumiale winksmiley.jpg
Dodam jeszcze ze zapytania SQL sa poprawne...


--------------------
przetwornik yt na czasie :)
Go to the top of the page
+Quote Post
erix
post 12.06.2009, 15:40:02
Post #2





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




A co mówi mysql_error" title="Zobacz w manualu PHP" target="_manual? snitch.gif


--------------------

ZCE :: Pisząc PW załączaj LINK DO TEMATU i TYLKO w sprawach moderacji :: jakiś błąd - a TREŚĆ BŁĘDU? :: nie ponaglaj z odpowiedzią via PW!
Go to the top of the page
+Quote Post
hondek
post 12.06.2009, 15:48:42
Post #3





Grupa: Zarejestrowani
Postów: 355
Pomógł: 50
Dołączył: 20.08.2007
Skąd: Częstochowa

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


mówi, ze no database selected :/

dodalem przed wykonaniem zapytania sql funkcje laczaca z sql'em i po wykonaniu rozlaczajaca i teraz dziala, ale myslalem ze w wystarczy w konstruktorze sie polaczyc z baza i dekonstruktorze rozlaczyc... poza tym dziwi mnie ze za 1 razem wyciaga z bazy dane a za 2 nie ;/

Ten post edytował hondek 12.06.2009, 15:57:29


--------------------
przetwornik yt na czasie :)
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 25.07.2025 - 08:06