Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP][MySQL]Porównanie
adrianozo
post
Post #1





Grupa: Zarejestrowani
Postów: 733
Pomógł: 4
Dołączył: 11.11.2009

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


Witam wszystkich. Mam problem z porównaniem.

  1. <?php
  2. $aukcje = 'SELECT `id` FROM `phpauction_users`';
  3. $idaukcje = mysql_query($aukcje);
  4. $user = 'SELECT `user` FROM `phpauction_auctions` WHERE `id` = '.$id.'';
  5. $iduser = mysql_query($user);
  6. while($pokazuser = mysql_fetch_array($iduser))
  7. {
  8. echo 'NICK UŻYTKOWNIKA: '.$pokazuser['user'].'<br />';
  9. }
  10. while($pokazaukcje = mysql_fetch_array($idaukcje))
  11. {
  12. echo 'ID UŻYTKOWNIKA: '.$pokazaukcje['id'].'<br />';
  13. }
  14. if($pokazaukcje['id'] == $pokazuser['user'])
  15. {
  16. echo ' | <a href="again.php?id='.$id.'">Exhibition again</a>';
  17. }
  18. ?>


Otrzymuje błąd Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in line 100

Linia 100 to:

Kod
while($pokazuser = mysql_fetch_array($iduser))

Nie wiem dlaczego tak jest
Go to the top of the page
+Quote Post
Blame
post
Post #2





Grupa: Zarejestrowani
Postów: 678
Pomógł: 124
Dołączył: 26.09.2009

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


Dostajesz błąd bo nie ma w bazie użytkownika o takim id i funkcja nic nie otrzymuje a nie przez porównanie.
Go to the top of the page
+Quote Post
adrianozo
post
Post #3





Grupa: Zarejestrowani
Postów: 733
Pomógł: 4
Dołączył: 11.11.2009

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


A właśnie jest taki użytkownik....
Go to the top of the page
+Quote Post
gigzorr
post
Post #4





Grupa: Zarejestrowani
Postów: 652
Pomógł: 47
Dołączył: 6.02.2010
Skąd: Radom

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


pewnie tu jest blad:
  1. $user = 'SELECT `user` FROM `phpauction_auctions` WHERE `id` = '.$id.'';


wyswietl zapytanie
  1. print_r($user);
Go to the top of the page
+Quote Post
adrianozo
post
Post #5





Grupa: Zarejestrowani
Postów: 733
Pomógł: 4
Dołączył: 11.11.2009

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


SELECT `user` FROM `phpauction_auctions` WHERE `id` = aec983ae12d63d6e70e99ee222b9240a więc wszystko jest ok
Go to the top of the page
+Quote Post
everth
post
Post #6





Grupa: Zarejestrowani
Postów: 782
Pomógł: 153
Dołączył: 21.07.2010

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


Na oko brakuje apostrofów. Spróbuj tak:
  1. $query = "SELECT `user` FROM `phpauction_auctions` WHERE `id` = '{$id}'";
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: 22.08.2025 - 13:29