Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] Problem z korzystaniem z mysql_result
Balon
post
Post #1





Grupa: Zarejestrowani
Postów: 422
Pomógł: 0
Dołączył: 14.12.2005
Skąd: Wałbrzych

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


  1. <?php
  2. $query_char= mysql_query('SELECT hp_char FROM fight WHERE user=$user');
  3. $query_mob= mysql_query('SELECT hp_mob FROM fight WHERE user=$user');
  4. $mob_hp = mysql_result($query_mob, 0, 0);
  5. $char_hp = mysql_result($query_char, 0, 0);
  6. ?>


taki kod wywala mi blad

Kod
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/soonhost/public_html/tury.php on line 35

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/soonhost/public_html/tury.php on line 36


w tej tabeli mam tylko jeden rekord . nie wiem dalczego to nie dziala... przeciez nie ma tu nigdzie zadnego bledu ...

prosze o pomoc

Ten post edytował Balon 9.03.2006, 19:08:57
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




  1. <?php
  2. $query_char= mysql_query('SELECT hp_char FROM fight WHERE user='.$user);
  3. ?>
podobnie z drugim
Go to the top of the page
+Quote Post
Balon
post
Post #3





Grupa: Zarejestrowani
Postów: 422
Pomógł: 0
Dołączył: 14.12.2005
Skąd: Wałbrzych

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


poprawilem jak mowiles

  1. <?php
  2. $query_char= mysql_query('SELECT hp_char FROM fight WHERE user='.$user);
  3. $query_mob= mysql_query('SELECT hp_mob FROM fight WHERE user='.$user);
  4. $mob_hp = mysql_result($query_mob, 0, 0);
  5. $char_hp = mysql_result($query_char, 0, 0);
  6. ?>

i nadal ten sam błąd....
Go to the top of the page
+Quote Post
NetJaro
post
Post #4





Grupa: Zarejestrowani
Postów: 475
Pomógł: 0
Dołączył: 1.04.2005
Skąd: Warszawa

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


Może daj na końcu LIMIT 1, 0 aby na 100% zwracało jeden wynik..
Go to the top of the page
+Quote Post
Balon
post
Post #5





Grupa: Zarejestrowani
Postów: 422
Pomógł: 0
Dołączył: 14.12.2005
Skąd: Wałbrzych

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


  1. <?php
  2. $query_char= mysql_query('SELECT hp_char FROM fight WHERE user='.$user.' LIMIT 1, 0');
  3. $query_mob= mysql_query('SELECT hp_mob FROM fight WHERE user='.$user.' LIMIT 1, 0');
  4. $mob_hp = mysql_result($query_mob, 0, 0);
  5. $char_hp = mysql_result($query_char, 0, 0);
  6. ?>


nadal to samo... a moze macie jakas inna funkcje ktora dzialala by podobnie... moglaby pobierac np tylko jeden wiersz z tabeli,....
Go to the top of the page
+Quote Post
Fipaj
post
Post #6





Grupa: Zarejestrowani
Postów: 691
Pomógł: 0
Dołączył: 19.01.2005
Skąd: Warszawa

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


A przypadkiem nie $_POST['user'] czy $_GET['user']?
Go to the top of the page
+Quote Post
Balon
post
Post #7





Grupa: Zarejestrowani
Postów: 422
Pomógł: 0
Dołączył: 14.12.2005
Skąd: Wałbrzych

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


  1. <?php
  2. $user=1;
  3. (...)
  4. // fight
  5. $query_char= mysql_query('SELECT hp_char FROM fight WHERE user='.$user);
  6. $query_mob= mysql_query('SELECT hp_mob FROM fight WHERE user='.$user);
  7. $mob_hp = mysql_result($query_mob, 0, 0);
  8. $char_hp = mysql_result($query_char, 0, 0);
  9. ?>


no i nie dziala nadal... probowalem teraz zrobic to tak

  1. <?php
  2. $query_char= mysql_query('SELECT hp_char FROM fight WHERE user='.$user);
  3. $query_mob= mysql_query('SELECT hp_mob FROM fight WHERE user='.$user);
  4. /*$mob_hp = mysql_result($query_mob, 0, 0);
  5. $char_hp = mysql_result($query_char, 0, 0);*/
  6. while($row = mysql_fetch_array($query_mob)){
  7. $mob_hp = $row['HP_MOB'];
  8. }
  9. while($row = mysql_fetch_array($query_char)){
  10. $char_hp = $row['HP_CHAR'];
  11. }
  12. ?>


ale nadal wywala blad...

Kod
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/soonhost/public_html/tury.php on line 37

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/soonhost/public_html/tury.php on line 40


wiec to wina samego zapytania... ale co z nim jest nie tak :/
Go to the top of the page
+Quote Post
NetJaro
post
Post #8





Grupa: Zarejestrowani
Postów: 475
Pomógł: 0
Dołączył: 1.04.2005
Skąd: Warszawa

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


Może w ogóle złe zapytanie wysyłasz :-) Sprawdź w phpMyAdmin'ie albo "ręcznie"..
Go to the top of the page
+Quote Post
mike
post
Post #9





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

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


A jakiego typu jest pole user? Pole tekstowe jakieś?
  1. <?php
  2.  
  3. $resQueryChar = mysql_query( "SELECT hp_char FROM fight WHERE user = '" . $user ."'" );
  4. $resQueryMob = mysql_query( "SELECT hp_mob FROM fight WHERE user = '" . $user . "'");
  5.  
  6. if( mysql_num_rows( $resQueryChar ) > 0 )
  7. {
  8. while( $arrRow = mysql_fetch_array( $resQueryChar ) )
  9. {
  10. $char_hp = $arrRow[ 'hp_char' ];
  11. }
  12. }
  13. else
  14. {
  15. echo 'zapytanie 1 nie zwróciło wyników';
  16. }
  17.  
  18.  
  19. if( mysql_num_rows( $resQueryMob ) > 0 )
  20. {
  21. while( $arrRow = mysql_fetch_array( $resQueryMob ) )
  22. {
  23. $char_mob = $arrRow[ 'hp_mob' ];
  24. }
  25. }
  26. else
  27. {
  28. echo 'zapytanie 2 nie zwróciło wyników';
  29. }
  30.  
  31. ?>

I jak teraz :?:
Go to the top of the page
+Quote Post
Balon
post
Post #10





Grupa: Zarejestrowani
Postów: 422
Pomógł: 0
Dołączył: 14.12.2005
Skąd: Wałbrzych

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


sprawdzilem... działa :/

  1. <?php
  2. $q = "SELECT * FROM fight";
  3. $query= mysql_query($q);
  4. /*$mob_hp = mysql_result($query_mob, 0, 0);
  5. $char_hp = mysql_result($query_char, 0, 0);*/
  6. while($row = mysql_fetch_array($query)){
  7. $mob_hp = $row['HP_MOB'];
  8. $char_hp = $row['HP_CHAR'];
  9. }
  10. ?>

przerobilem kod tak ale nadal nie dziala... a zapytanie ma jak na teraz chyba najprostsza mozliwa forme zapytania do bazy... i nadal nie działa

Mike_Mech ja przeksztalcilem kod w inny sposob i nie chce juz zmieniac go spowrotem bo bede musial zmieiniac reszte... ale to jest niemozliwe ze takie zapytanie nie dziala...

Ten post edytował Balon 9.03.2006, 20:27:15
Go to the top of the page
+Quote Post
mike
post
Post #11





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

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


Skorzystaj z funkcji mysql_error() i mysql_errno() żeby znaleść ewentualny błąd.
Go to the top of the page
+Quote Post
Balon
post
Post #12





Grupa: Zarejestrowani
Postów: 422
Pomógł: 0
Dołączył: 14.12.2005
Skąd: Wałbrzych

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


No i dzięki wielkie Mike_Mech ... moj blad.. okazalo sie ze nie nadalem usera bazie i dlatego nie działało... teraz wszystko śmiga (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

dzięki wielkie (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
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 - 15:32