Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MYSQL I PHP] Problem z fetch_assoc
elwierka
post
Post #1





Grupa: Zarejestrowani
Postów: 66
Pomógł: 0
Dołączył: 26.12.2007

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


Witajcie

Właśnie próbuję napisać aplikację do składania zamówień przez internet i mam problem z odczytywaniem wyników zapytań z bazy danych mysql :shout: . Pobieram dane z bazy i zwracam jako obiekt.
(fragment kodu)
  1. $lacz = con_to_db(); //funkcja ustanawiająca połączenie z bazą
  2. $zapytanie = "select * from klienci where login = '".$login."'";
  3. $wynik = $lacz->query($zapytanie);
  4.  
  5. if (!$wynik) {
  6. throw new Exception('Błąd.');
  7. }
  8.  
  9. $ilosc = $wynik->num_rows;
  10.  
  11. if($ilosc > 0) {
  12. while($rzad = $wynik->fetch_assoc()) {
  13. echo $rzad['adres']."<br />;
  14. echo $rzad['nip']."<br />;
  15. }
  16. } else {
  17. echo "Komunikat o błędzie";
  18. }

Niestety, jak odczytuję wyniki za pomocą fetch_assoc(), skrypt podczas wykonywania się, resetuje połączenie..."Połaczenie zostało przerwane podczas negocjacji" - pojawia się komunikat w tym stylu.

Nie ma jednak żadnego problemu, jeśli zamiast fetch_assoc() użyję fetch_row i odczytuję wyniki jako $rzad[0], $rzad[1] itd.....

Tak samo jest, jeśli chcę odczytać dane o wszystkich osobach, zawarte w tabeli klienci (nie dane konkretnej osoby).

Od kilku dni nie mogę sobie poradzić z tym problemem...a muszę dalej pisać aplikację...Czy ktoś z Was wie o co może chodzić? Dlaczego tak się dzieje?

Z góry dzięki za odp.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
elwierka
post
Post #2





Grupa: Zarejestrowani
Postów: 66
Pomógł: 0
Dołączył: 26.12.2007

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


odpowiada:

  1. object(mysqli_result)#2 (0) { }


W katalogu serwera /log znalazlam plik error i po próbie wywołania tego nieszczęsnego skryptu pojawiła się taka linijka informacji:

  1. [Tue Apr 20 20:56:28 2010] [notice] Parent: child process exited with status 3221225477 -- Restarting.
  2. httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.18 for ServerName
  3. [Tue Apr 20 20:56:30 2010] [notice] Apache/2.2.11 (Win32) PHP/5.2.13 configured -- resuming normal operations
  4. [Tue Apr 20 20:56:30 2010] [notice] Server built: Dec 10 2008 00:10:06
  5. [Tue Apr 20 20:56:30 2010] [notice] Parent: Created child process 1668
  6. httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.18 for ServerName
  7. httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.18 for ServerName
  8. [Tue Apr 20 20:56:30 2010] [notice] Child 1668: Child process is running
  9. [Tue Apr 20 20:56:30 2010] [notice] Child 1668: Acquired the start mutex.
  10. [Tue Apr 20 20:56:30 2010] [notice] Child 1668: Starting 64 worker threads.
  11. [Tue Apr 20 20:56:31 2010] [notice] Child 1668: Starting thread to listen on port 80.
  12. [Tue Apr 20 20:56:31 2010] [notice] Parent: child process exited with status 3221225477 -- Restarting.
  13. httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.18 for ServerName
  14. [Tue Apr 20 20:56:32 2010] [notice] Apache/2.2.11 (Win32) PHP/5.2.13 configured -- resuming normal operations
  15. [Tue Apr 20 20:56:32 2010] [notice] Server built: Dec 10 2008 00:10:06
  16. [Tue Apr 20 20:56:32 2010] [notice] Parent: Created child process 2512
  17. httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.18 for ServerName
  18. httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.18 for ServerName
  19. [Tue Apr 20 20:56:32 2010] [notice] Child 2512: Child process is running
  20. [Tue Apr 20 20:56:32 2010] [notice] Child 2512: Acquired the start mutex.
  21. [Tue Apr 20 20:56:32 2010] [notice] Child 2512: Starting 64 worker threads.
  22. [Tue Apr 20 20:56:32 2010] [notice] Child 2512: Starting thread to listen on port 80.




Nie wiem, może jakieś ustawienia serwera muszę zmienić? Może w php.ini....nie wiem co się dzieje ale taki głupi błąd blokuje mnie z pisaniem już od dwóch dni (IMG:style_emoticons/default/wstydnis.gif)

A jeszcze w pliku serwera /log/access jest taki zapis:

  1. 127.0.0.1 - - [20/Apr/2010:21:21:57 +0200] "GET /wsh/wsh/produkty.php HTTP/1.1" 200 1339
  2. 127.0.0.1 - - [20/Apr/2010:21:21:57 +0200] "GET /wsh/wsh/includes/css/style.css HTTP/1.1" 304 -
  3. 127.0.0.1 - - [20/Apr/2010:21:22:04 +0200] "GET /wsh/wsh/produkty.php HTTP/1.1" 200 176


treść tego skrypciku zapisałam dla testów w pliku produkty.php
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 7.10.2025 - 03:31