Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [SQL] Problem przy pobieraniu danych z 2 tabel
free
post
Post #1





Grupa: Zarejestrowani
Postów: 269
Pomógł: 0
Dołączył: 6.02.2006

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


Struktura tabel:
box:
Kod
`id` int(11) NOT NULL auto_increment,
  `txt` text NOT NULL,
  `idusera` int(6) NOT NULL default '0',
  `data` varchar(50) NOT NULL default '',

users
Kod
`user_id` int(11) NOT NULL auto_increment,
  `ksywa` varchar(100) NOT NULL default '',
...

Probuje je polaczyc by otrzymac nazwe usera /ksywe z bazy users/ zanajc jego idusera /z bazy box/. Kluczem łączącym obie tabele jest idusera w box oraz user_id w users.
Stosuje :
  1. <?php
  2. $pytbox = "SELECT id, txt, idusera, data, user_id, ksywa FROM box88 b, users88 u 
  3. WHERE idusera.b=user_id.u ORDER BY data DESC LIMIT 9";
  4.  $resbox = mysql_query($pytbox);
  5.  while ($box = mysql_fetch_array($resbox))
  6. {
  7. $tresc=$box['txt'];
  8. $data=$box['data'];
  9. $idbox=$box['id'];
  10. $idusera=$box['idusera'];
  11. $ksywa=$box['ksywa'];
  12. echo "$ksywa <br />$idbox $tresc ::";
  13. ebox($idbox, $idusera);
  14. echo " ::<br /> $data <br /><br /> ";
  15. }
  16. ?>

Błąd w 5 lini : Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in...

Ten post edytował free 10.10.2006, 17:02:20
Go to the top of the page
+Quote Post
bim2
post
Post #2





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


idusera.b=user_id.u nie tak pierw dajesz prefix czyli b.idusera itd. (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) polecam mysql_error()
Go to the top of the page
+Quote Post
free
post
Post #3





Grupa: Zarejestrowani
Postów: 269
Pomógł: 0
Dołączył: 6.02.2006

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


Dzieki poprawiłem i działą :-)
Dawno nie łączyłem w ten sposob stą pomyłka ;-)
Go to the top of the page
+Quote Post

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: 25.08.2025 - 22:51