Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem z wynikami
pilat
post 6.01.2006, 19:17:31
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 6.01.2006

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


Witam.
Mam problem z wyświetlaniem wyników.

Oto błąd:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\usr\krasnal\www\shop\browse_prints.php on line 25

A to mój skrypt:

  1. <?php
  2.  
  3. $page_title = 'Przeglądanie odbitek';
  4. include_once ('includes/header.html');
  5.  
  6. require_once ('mysql_connect.php');
  7.  
  8. if (isset($_GET['aid'])) {
  9. $query = "SELECT * FROM sklep, prints ASC";
  10. }
  11.  
  12. echo '<table border="1" width="100%" cellspacing="3" cellpadding="3" algin="center">
  13. <tr>
  14. <td algin="left" width="5%">Lp.</b></td>
  15. <td algin="left" width="20%">Nr. katalogowy</b></td>
  16. <td algin="left" width="20%">Produkt</b></td>
  17. <td algin="left" width="5%">Ilość</b></td>
  18. <td algin="left" width="20%">Cena (netto)</b></td>
  19. <td algin="left" width="20%">Wartość (netto)</b></td>
  20. <td algin="left" width="10%">VAT</b></td>
  21. <td algin="left" width="20%">Wartość (brutto)</b></td>
  22. </tr>';
  23.  
  24. $result = mysql_query ($query);
  25. while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
  26. echo "<tr>
  27. <td algin="left">{$row['print_id']}</td>
  28. <td algin="left">{$row['nr_k']}</td>
  29. <td algin="left">{$row['p_pr_id']}</td>
  30. <td algin="left">{$row['ilosc']}</td>
  31. <td algin="right">{$row['p_price_n']} zł</td>
  32. <td algin="right">{$row['p_war_n']} zł</td>
  33. <td algin="right">{$row['p_vat']} zł</td>
  34. <td algin="right">{$row['p_war_b']} zł</td>
  35.  
  36. </tr>n"; 
  37.  
  38. }
  39. echo '<table>' ;
  40. include_once ('includes/footer.html');
  41. ?>


Co może być tego przyczyną?
Go to the top of the page
+Quote Post
intol
post 6.01.2006, 21:03:01
Post #2





Grupa: Zarejestrowani
Postów: 110
Pomógł: 1
Dołączył: 29.07.2003

Ostrzeżenie: (10%)
X----


if (isset($_GET['aid'])) {}

jeżeli aid nie jest ustawione, $query jest puste, a mimo to wykonujesz $result = mysql_query ($query); .


--------------------
Zbiór najlepszych technologicznych artykułów (programowanie, internet, linux)
Go to the top of the page
+Quote Post
tiraeth
post 6.01.2006, 21:31:20
Post #3





Grupa: Przyjaciele php.pl
Postów: 1 789
Pomógł: 41
Dołączył: 30.10.2003
Skąd: Wrocław

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


  1. <?php
  2.  
  3. $page_title = 'Przeglądanie odbitek';
  4. include_once ('includes/header.html');
  5.  
  6. require_once ('mysql_connect.php');
  7.  
  8. if (isset($_GET['aid'])) {
  9. // BLAD W ZAPYTANIU BYL
  10. $query = "SELECT * FROM sklep, prints ORDER BY sklep, prints ASC";
  11. }
  12.  
  13. echo '<table border="1" width="100%" cellspacing="3" cellpadding="3" align="center">
  14. <tr>
  15. <td algin="left" width="5%">Lp.</b></td>
  16. <td algin="left" width="20%">Nr. katalogowy</b></td>
  17. <td algin="left" width="20%">Produkt</b></td>
  18. <td algin="left" width="5%">Ilość</b></td>
  19. <td algin="left" width="20%">Cena (netto)</b></td>
  20. <td algin="left" width="20%">Wartość (netto)</b></td>
  21. <td algin="left" width="10%">VAT</b></td>
  22. <td algin="left" width="20%">Wartość (brutto)</b></td>
  23. </tr>';
  24.  
  25. if(isset($_GET['aid']))
  26. {
  27. // TUTAJ INSTRUKCJA WARUNKOWA...
  28. $result = mysql_query ($query);
  29. while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
  30. echo "<tr>
  31. <td algin="left">{$row['print_id']}</td>
  32. <td algin="left">{$row['nr_k']}</td>
  33. <td algin="left">{$row['p_pr_id']}</td>
  34. <td algin="left">{$row['ilosc']}</td>
  35. <td algin="right">{$row['p_price_n']} zł</td>
  36. <td algin="right">{$row['p_war_n']} zł</td>
  37. <td algin="right">{$row['p_vat']} zł</td>
  38. <td algin="right">{$row['p_war_b']} zł</td>
  39.  
  40. </tr>n"; 
  41. }
  42. }
  43. else
  44. {
  45. <td algin=\"right" colspan="8">Nie wybrano identyfikatora</td>
  46. }
  47. echo '<table>' ;
  48. include_once ('includes/footer.html');
  49. ?>
Go to the top of the page
+Quote Post
pilat
post 7.01.2006, 07:32:32
Post #4





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 6.01.2006

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


Dzięki za pomoc. smile.gif
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: 7.07.2025 - 12:10