Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> mysql_fetch_array():, Wszystko dobrze a jednak mu cos nie pasi
Haptor
post 11.09.2005, 12:42:18
Post #1





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 15.05.2005

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


Witam! Jestem strasznie zirytowany dry.gif Robie sobie stronke i wszystko jest ok ... dane z bazy mysql sa prezentowane i mimo to powstaje błąd

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/w/n/z/wnz/www/func.php on line 8
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Tresc pliku func.php wyglada nastepujaco:

  1. <?
  2.  
  3. function WierszM(){
  4.  
  5. $pol=mysql_connect("mysql.60free.ovh.org","*********","********");
  6. mysql_select_db ("wnz", $pol);
  7. $wyn=mysql_query ("SELECT * FROM milosne WHERE id = $id", $pol);
  8. while($poka=mysql_fetch_array($wyn)) // tu jest niby blad
  9. {
  10. echo"<b><font color='#FeFec0'>".$poka["tytul"];
  11. echo"</font></b>".$poka["tresc"];
  12. }
  13. }
  14. ?>


Prosilbym o pomoc gdyz kazdy nastepny dzien pogarsza moia sytuacje psycho-fizyczna blink.gif

Z góry thx
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 11)
chmolu
post 11.09.2005, 12:49:25
Post #2





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 8.10.2004

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


Nie widzę w funkcji WierszeM() zmiennej $id. Skąd funkcja ma wiedzieć co to za zmienna?
Go to the top of the page
+Quote Post
Haptor
post 11.09.2005, 12:52:37
Post #3





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 15.05.2005

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


No juz widzi zmienna $id

  1. <?
  2.  
  3. function WierszM(){
  4.  
  5. global $id;
  6.  
  7. $pol=mysql_connect("mysql.60free.ovh.org","login","pass");
  8. mysql_select_db ("wnz", $pol);
  9. $wyn=mysql_query ("SELECT * FROM milosne WHERE id = $id", $pol);
  10. while($poka=mysql_fetch_array($wyn))//tu jest niby blad
  11. {
  12. echo"<b><font color='#FeFec0'>".$poka["tytul"];
  13. echo"</font></b>".$poka["tresc"];
  14. }
  15. }
  16. ?>


a mimo to dalej nie działa..... jestem zalamany.... mamo ja tu gine!!

Ten post edytował Haptor 11.09.2005, 13:01:45
Go to the top of the page
+Quote Post
luinnar
post 11.09.2005, 13:23:19
Post #4





Grupa: Zarejestrowani
Postów: 155
Pomógł: 0
Dołączył: 15.07.2004
Skąd: Bielsko-Biała

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


Czy $id na 100% jest intem? Jak nie to może się sypać z tego powodu.


--------------------
notDevBlog - devblog.luinnar.com
Go to the top of the page
+Quote Post
tiraeth
post 11.09.2005, 13:28:02
Post #5





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

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


  1. <?
  2. function WierszM()
  3. {
  4.  global $id;
  5.  
  6.  $pol = mysql_connect("host:port","login","haslo") or die(mysql_error());
  7.  mysql_select_db("baza", $pol) or die(mysql_error());
  8.  
  9.  $wyn = mysql_query("SELECT * FROM milosne WHERE id = ".(int)$id, $pol) or die(mysql_error());
  10.  
  11.  while($poka=mysql_fetch_array($wyn))
  12.  {
  13. echo"<b><font color='#FeFec0'>".$poka["tytul"];
  14. echo"</font></b>".$poka["tresc"];
  15.  }
  16. }
  17. ?>
Go to the top of the page
+Quote Post
Haptor
post 11.09.2005, 19:36:58
Post #6





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 15.05.2005

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


BOSHE no nie idzie pokaze wam jak teraz mam

  1. <?
  2. function WierszM(){
  3. global $m;
  4. $pol=mysql_connect("mysql.60free.ovh.org","******","*********");
  5. mysql_select_db ("wnz", $pol);
  6. $wyn=mysql_query ("SELECT * FROM milosne WHERE id = $m", $pol);
  7. while($poka=mysql_fetch_assoc($wyn))
  8. {
  9. echo"<b><center><font color='#FeFec0'>".$poka["tytul"];
  10. echo"</font><br><br></b>".$poka["tresc"];
  11. }
  12. }
  13. ?>


a tresc błedu

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/w/n/z/wnz/www/func.php on line 7

BOSHE HELP...... blink.gif juz na łeb dostaje
Go to the top of the page
+Quote Post
czachor
post 11.09.2005, 19:40:35
Post #7





Grupa: Zarejestrowani
Postów: 897
Pomógł: 40
Dołączył: 16.12.2003
Skąd: Warszawa

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


Co zwraca mysql_error() po zapytaniu?


--------------------
how many SEO experts does it take to change a light bulb,lightbulb,light,bulb,lamp,lighting,switch,sex,xxx
5-Reasons-why-you-should-NEVER-fix-a-computer-for-free
Go to the top of the page
+Quote Post
Haptor
post 11.09.2005, 19:47:10
Post #8





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 15.05.2005

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


No pokazuje takie cos

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

teraz juz tylko to juz nie ma innej tresci ^^ to juz cos:P
Go to the top of the page
+Quote Post
czachor
post 11.09.2005, 20:16:55
Post #9





Grupa: Zarejestrowani
Postów: 897
Pomógł: 40
Dołączył: 16.12.2003
Skąd: Warszawa

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


No to masz niepoprawnie sformułowane zapytanie. Spróbuj tak:
  1. <?php
  2. $wyn = mysql_query ('SELECT * FROM milosne WHERE id = '' . $m . ''', $pol);
  3. ?>


--------------------
how many SEO experts does it take to change a light bulb,lightbulb,light,bulb,lamp,lighting,switch,sex,xxx
5-Reasons-why-you-should-NEVER-fix-a-computer-for-free
Go to the top of the page
+Quote Post
pawsul
post 11.09.2005, 20:19:41
Post #10





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 11.09.2005

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


a jesli to nie pomoze to zobacz tak
  1. <?php
  2. $wyn=mysql_query ("SELECT * FROM milosne WHERE id = '$m' ", $pol);
  3. ?>


Ten post edytował pawsul 11.09.2005, 20:20:21
Go to the top of the page
+Quote Post
tiraeth
post 12.09.2005, 14:45:32
Post #11





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

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


Ale przecież my mamy zgadywać, że zmienna $id (czy $m) to string a nie integer.... powinieneś dostać ostrzeżenie za nie dostarczenie nam szczegółowych informacji nt. zmiennych użytych w zapytaniu. Ostatni raz widzę, że ktoś mówi, że jest błąd a my go "błędnie" (z jego winy) poprawiamy...
Go to the top of the page
+Quote Post
sajborg
post 12.09.2005, 14:45:56
Post #12





Grupa: Zarejestrowani
Postów: 271
Pomógł: 0
Dołączył: 20.08.2003
Skąd: Szczecinek

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


Ale wy kombinujecie z tym ja

  1. <?php
  2. $wyn=mysql_query ("SELECT * FROM milosne WHERE id = '".$m."' ", $pol);
  3.  
  4. ?>


I tyle bedzie dzialac na 100%


--------------------
Warsztat: gPHPEdit | Linux 2.6.17-11-generic (Ubuntu)
Sprzęt: Noteook BenQ A33E
___________________________________________________
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: 28.06.2025 - 21:29