Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> problem z obsługą MySQL'a
damar
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 2.03.2005

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


Mam następujący kod php:
  1. <?
  2. print(&#092;"<html>n\");
  3. print(&#092;"<head>n\");
  4. print(&#092;"<title>Listing</title>n\");
  5. print(&#092;"</head>n\");
  6.  
  7. print(&#092;"<body>n\");
  8. $mysql_link=mysql_connect(&#092;"localhost\",\"httpd\", \"\");
  9. if($mysql_link==false) echo &#092;"FUCK\";
  10. mysql_select_db(&#092;"sklep\");
  11.  
  12. $result=mysql_query(&#092;"SELECT * FROM catalog\");
  13.  
  14. print(&#092;"<table border=\"0\">n\");
  15. print(&#092;"<tr>n\");
  16. print(&#092;"<td bgcolor=\"#CCCCCC\"><b>Towar</b></td>n\");
  17. print(&#092;"<td bgcolor=\"#CCCCCC\"><b>Cena</b></td>n\");
  18. print(&#092;"</tr>n\");
  19. echo 'Zapytanie zwróciło '.mysql_num_rows($result).' wyników';
  20.  
  21. while($row=mysql_fetch_row($result))
  22. {
  23. $item_ID=$row[0];
  24. $item_Name=$row[1];
  25. $item_Price=$row[2];
  26.  
  27. print(&#092;"<tr>n\");
  28. print(&#092;"<td>$item_Name</td>n\");
  29. print(&#092;"<td align\"right\">$item_Price</td>n\");
  30. print(&#092;"</tr>n\");
  31. }
  32. print(&#092;"</table>n\");
  33. print(&#092;"<b>$mysql_link</b>\");
  34. print(&#092;"</body>n\");
  35. print(&#092;"</html>n\");
  36. ?>


i wywala mi ostrzeżenie:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\usr\krasnal\www\... on line 19
Zapytanie zwróciło wyników
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\usr\krasnal\www\... on line 21


Czy ktoś mi powie dlaczego tak jest?(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 6)
UoX
post
Post #2





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 3.03.2005

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


Spróbuj wywołać mysql_num_rows($result) poza funkcją echo.
Go to the top of the page
+Quote Post
damar
post
Post #3





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 2.03.2005

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


nic z tego. dalej to samo. Nie wiem, może trzeba zmienić atrybuty tabeli. No ale przecież pod windą wszystkie pliki są defaultowo dostepne do odczytu.
Brak słów (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
Fibolg
post
Post #4





Grupa: Zarejestrowani
Postów: 123
Pomógł: 0
Dołączył: 1.12.2003
Skąd: Chełmno

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


Może funkcja count() MySQL'a?
Go to the top of the page
+Quote Post
shima
post
Post #5





Grupa: Zarejestrowani
Postów: 245
Pomógł: 0
Dołączył: 9.09.2002

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


Użyj die" title="Zobacz w manualu PHP" target="_manual dla mysql_query" title="Zobacz w manualu PHP" target="_manual
Go to the top of the page
+Quote Post
Vertical
post
Post #6





Grupa: Zarejestrowani
Postów: 848
Pomógł: 0
Dołączył: 7.07.2004
Skąd: Wrocław

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


To znaczy, że nie ma takiej bazy albo tabeli, albo gdzieś się pomyliłeś w zapytaniu. W przypadku MySQL 4.0 taki błąd wysypuje też wtedy, kiedy baza ma taką nazwę jak tabela
Go to the top of the page
+Quote Post
damar
post
Post #7





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 2.03.2005

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


Poradziłem sobie (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) . Problemem był brak uprawnienień do bazy. Z konta roota nadałem uprawnienia do bazy "sklep" użytkownikowi ,z którego konta korzystałem.
Ale dzięki za podpowiedzi (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

pozdrawiam
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: 23.08.2025 - 01:31