Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php][mysql] Rekordy i while
Piotrwusek
post
Post #1





Grupa: Zarejestrowani
Postów: 399
Pomógł: 7
Dołączył: 11.06.2007
Skąd: Poznan

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


plik.php
  1. <?php
  2. mysql_connect('host', 'użytkownik', 'hasło') or die ("Nie masz uprawnien");
  3.  
  4.  
  5. $pytanie = mysql_query("SELECT 8 FROM plan_poniedzialek");
  6. while($ostat = mysql_fetch_assoc($pytanie));
  7. {
  8.  print_r($ostat);
  9. }
  10.  
  11.  
  12.  
  13.  
  14. ?>


Co jest nie tak z while?

Pracuje na PHP 4

Ten post edytował Piotrwusek 11.07.2007, 09:19:34
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 16)
php programmer
post
Post #2





Grupa: Zarejestrowani
Postów: 1 045
Pomógł: 5
Dołączył: 8.11.2004
Skąd: trójmiasto

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


Nie tak w while jest to że dałeś średnik

  1. <?php
  2. while($ostat = mysql_fetch_assoc($pytanie)); <-- ten średnik niedobry
  3. ?>


Ten post edytował php programmer 11.07.2007, 09:21:55
Go to the top of the page
+Quote Post
Cysiaczek
post
Post #3





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Co to jest to 8? Ilosć rekordów? To się inaczej robi.
  1. <?php
  2. $sql="SELECT * FROM plan_poniedzialek LIMIT 8";
  3. ?>


O to chodzi?

Pozdrawiam.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
Piotrwusek
post
Post #4





Grupa: Zarejestrowani
Postów: 399
Pomógł: 7
Dołączył: 11.06.2007
Skąd: Poznan

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


8 to niżej masz post a w nim strukturę tabeli wiec zobacz

Ten post edytował Piotrwusek 11.07.2007, 09:53:05
Go to the top of the page
+Quote Post
Cysiaczek
post
Post #5





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Uhu. Czyli chodzi o nieśmiertelny średnik tongue.gif


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
Piotrwusek
post
Post #6





Grupa: Zarejestrowani
Postów: 399
Pomógł: 7
Dołączył: 11.06.2007
Skąd: Poznan

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


wcale nie bo bez średnika też jest problem

wyskakuje coś takiego

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/kwserwer/ftp/plan.php on line 18

a kod jest taki
plik.php
  1. <?php
  2. mysql_connect('host', 'użytkownik', 'hasło') or die ("Nie masz uprawnien");
  3.  
  4.  
  5. $pytanie = mysql_query("SELECT 8 FROM plan_poniedzialek");
  6. while($ostat = mysql_fetch_assoc($pytanie))
  7. {
  8.  print_r($ostat);
  9. }
  10.  
  11.  
  12.  
  13.  
  14. ?>
Go to the top of the page
+Quote Post
Cysiaczek
post
Post #7





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




No żeś namieszał... ja też.
8 nie może być nazwą tabeli, bo jest nią plan_poniedziałek... czym zatem jest to 8?


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
Piotrwusek
post
Post #8





Grupa: Zarejestrowani
Postów: 399
Pomógł: 7
Dołączył: 11.06.2007
Skąd: Poznan

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


żebyśmy sie zrozumieli to jest struktura w bazie danych
  1. --
  2. -- Struktura tabeli dla `plan_poniedzialek`
  3. --
  4.  
  5. CREATE TABLE `plan_poniedzialek` (
  6. `8` varchar(20) NOT NULL DEFAULT '',
  7. `850` varchar(20) NOT NULL DEFAULT '',
  8. `945` varchar(20) NOT NULL DEFAULT '',
  9. `1040` varchar(20) NOT NULL DEFAULT '',
  10. `1130` varchar(20) NOT NULL DEFAULT '',
  11. `1240` varchar(20) NOT NULL DEFAULT '',
  12. `1315` varchar(20) NOT NULL DEFAULT '',
  13. `1430` varchar(20) NOT NULL DEFAULT '',
  14. `1520` varchar(20) NOT NULL DEFAULT ''
  15. )


więc co robie źle

Ten post edytował Piotrwusek 11.07.2007, 09:51:58
Go to the top of the page
+Quote Post
Stark
post
Post #9





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 30.09.2006

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


Moze o to chodzi:

  1. <?php
  2. mysql_connect('host', 'użytkownik', 'hasło') or die ("Nie masz uprawnien");
  3.  
  4.  
  5. $pytanie = mysql_query("SELECT 8 FROM plan_poniedzialek");
  6. ?>
Go to the top of the page
+Quote Post
Cysiaczek
post
Post #10





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




To może pokaż jaki to błąd?


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
Piotrwusek
post
Post #11





Grupa: Zarejestrowani
Postów: 399
Pomógł: 7
Dołączył: 11.06.2007
Skąd: Poznan

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


  1. <?php
  2.  
  3.  
  4. mysql_connect('host', 'użytkownik', 'hasło') or die ("Nie masz uprawnien");
  5.  
  6. mysql_select_db("kwserwer_5");
  7.  
  8. $pytanie = mysql_query("SELECT 8 FROM plan_poniedzialek");
  9. while($ostat = mysql_fetch_assoc($pytanie))
  10. {
  11.  print($ostat);
  12. }
  13.  
  14.  
  15.  
  16.  
  17. ?>


Teraz nie ma błędu naroście ale wyświetla się słowo Array
a ja che żeby wyświetlał sie rekord
można to zobaczyć na stronie kwserwer.nazwa.pl/plan.php

Ten post edytował Piotrwusek 11.07.2007, 10:43:47
Go to the top of the page
+Quote Post
Stark
post
Post #12





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 30.09.2006

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


Zmienna 'ostat' jest tablica, wpisz sobie var_dump($ostat) i zobacz co wyrzuci.
Go to the top of the page
+Quote Post
Piotrwusek
post
Post #13





Grupa: Zarejestrowani
Postów: 399
Pomógł: 7
Dołączył: 11.06.2007
Skąd: Poznan

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


wyrzuciło coś takiego

array(1) { [8]=> string(1) "8" }
Go to the top of the page
+Quote Post
Stark
post
Post #14





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 30.09.2006

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


No to najwyrazniej w polu '8' masz wartosc '8'. Jesli chcesz ja wyswietlic to w petli zamiast print($ostat); napisz print($ostat[8]);.

Ten post edytował Stark 11.07.2007, 10:50:11
Go to the top of the page
+Quote Post
Piotrwusek
post
Post #15





Grupa: Zarejestrowani
Postów: 399
Pomógł: 7
Dołączył: 11.06.2007
Skąd: Poznan

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


W polu 8 mam wartość sfinks

Chcę w proty sposób wyświetlić rekord na stronie czy to takie trudne
Go to the top of the page
+Quote Post
Stark
post
Post #16





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 30.09.2006

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


Najwyrazniej...

Sproboj jeszcze tak:

  1. <?php
  2. $pytanie = mysql_query("SELECT `8` FROM plan_poniedzialek");
  3. ?>
Go to the top of the page
+Quote Post
Piotrwusek
post
Post #17





Grupa: Zarejestrowani
Postów: 399
Pomógł: 7
Dołączył: 11.06.2007
Skąd: Poznan

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


  1. <?php
  2. mysql_connect('host', 'użytkownik', 'hasło') or die ("Nie masz uprawnien");
  3.  
  4. mysql_select_db("kwserwer_5");
  5.  
  6. $pytanie = mysql_query("SELECT * FROM plan_poniedzialek");
  7. while($ostat = mysql_fetch_assoc($pytanie))
  8. {
  9. print($ostat[8]);
  10. }
  11.  
  12.  
  13.  
  14. ?>


zrobiłem tak i nażrecie działa

Dzięki wszystkim
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 Aktualny czas: 19.08.2025 - 04:59