Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php+mysq] blad w skrypcie
touse
post 12.01.2007, 11:34:51
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 12.01.2007

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


Witam po wykonaniu skryptu perser zwraca mi nastepujacy komunikat bledu

Cytat
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\webserv\www\public_html\helpdesk\index.php on line 120


a linia tego kodu to:

  1. <table width="400" border="0" cellpadding="5" align="center">
  2. <tr><td>
  3. <hr align="right" size="1" width="400" noshade>
  4. </td></tr>
  5. <?
  6. while($row = mysql_fetch_array($result)) {
  7.  ?> <tr><td> <?
  8.  if($last_date == $row["date"]): ?>
  9.  <p><b><? echo $row["time"] ?></b>
  10.  <?else:?>
  11.  <p><? echo $row["time"]?> - <b><? echo $row["date"]?></b>
  12.  <?endif;
  13.  $cat_num = $row["category_id"];
  14.  $cat_result = mysql_query("select categories.category from helpdesk, categories where helpdesk.categor
    y_id = categories.category_id and helpdesk.category_id = '$cat_num'"
    );
  15.  $cat = mysql_fetch_array($cat_result);
  16.  ?>
  17.  <br>Kategoria: <i><? echo $cat["category"] ?></i>
  18.  <p><? echo "<b>".$row["title"]."</b>n" ?>
  19.  <p><? echo $row["intro"] ?><br>
  20.  <?
  21.  printf("n<p><a href="index.php?more=%s">[<i>Rozwiązanie Problemu</i>]</a>n", $row["news_id"]);
  22.  printf("n <a href="index.php?add_comment=%s"><i>Dodaj komentarz</i></a>n", $row["news_id"]);
  23.  $last_date = $row["date"];
  24.  ?>
  25.  <hr align="right" size="1" width="400" noshade>
  26.  </td></tr>
  27.  <?
  28. }
  29. ?> </table> <?


Nie wiem co jest nie tak wczesniej stosowany mysql_fetch_array() np:

  1. <?php
  2. }
  3.  function enter_post($author, $password, $title, $intro, $more, $category) {
  4. connect();
  5. $sql = "select * from authors where author_name = '$author'";
  6. $result = mysql_fetch_array($sql);
  7. $row = mysql_fetch_array($result);
  8. if($row["author_password"] !=$password):
  9.  print("<h1>Podane hasło jest nieprawidłowe</h1>");
  10. else:
  11.  $author = $row["author_id"];
  12.  $time = date("H:i:s");
  13.  $date = date("y-m-d");
  14.  $sql = "insert into helpdesk VALUES(NULL,'$title','$intro','$more','$author','$category','$date','$time')";
  15.  mysql_query($sql);
  16. endif;
  17. }
  18. ?>


i kod wykonywany jest pomyslnie Moglbym prosic o pomoc w miare mozliwosci questionmark.gif
Go to the top of the page
+Quote Post
kossa
post 12.01.2007, 11:48:32
Post #2





Grupa: Zarejestrowani
Postów: 1 165
Pomógł: 9
Dołączył: 9.04.2002
Skąd: Toruń

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


Komunikat ten oznacza że masz błąd w zapytaniu SQL. Sparwdz nazwy tabel, kolumn.

Łukasz


--------------------
Go to the top of the page
+Quote Post
touse
post 12.01.2007, 11:52:29
Post #3





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 12.01.2007

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


baza wyglada tak:

  1. -- Baza danych: `itsolution`
  2. --
  3.  
  4. -- --------------------------------------------------------
  5.  
  6. --
  7. -- Struktura tabeli dla `categories`
  8. --
  9.  
  10. CREATE TABLE `categories` (
  11. `category_id` int(11) NOT NULL AUTO_INCREMENT,
  12. `category` varchar(32) DEFAULT NULL,
  13. PRIMARY KEY (`category_id`)
  14. ) TYPE=MyISAM AUTO_INCREMENT=9 ;
  15.  
  16. --
  17. -- Zrzut danych tabeli `categories`
  18. --
  19.  
  20. INSERT INTO `categories` VALUES (1, 'Microsoft Windows');
  21. INSERT INTO `categories` VALUES (2, 'Linux/Unix');
  22. INSERT INTO `categories` VALUES (3, 'Software');
  23. INSERT INTO `categories` VALUES (4, 'Hardware');
  24. INSERT INTO `categories` VALUES (5, 'Sieci');
  25. INSERT INTO `categories` VALUES (6, 'Wirusy');
  26. INSERT INTO `categories` VALUES (7, 'IT Solution');
  27. INSERT INTO `categories` VALUES (8, 'Inne');
  28.  
  29. -- --------------------------------------------------------
  30.  
  31. --
  32. -- Struktura tabeli dla `comments`
  33. --
  34.  
  35. CREATE TABLE `comments` (
  36. `comment_id` int(11) NOT NULL AUTO_INCREMENT,
  37. `news_id` int(11) DEFAULT NULL,
  38. `user_id` int(11) DEFAULT NULL,
  39. `comment` text,
  40. PRIMARY KEY (`comment_id`)
  41. ) TYPE=MyISAM AUTO_INCREMENT=1 ;
  42.  
  43. --
  44. -- Zrzut danych tabeli `comments`
  45. --
  46.  
  47.  
  48. -- --------------------------------------------------------
  49.  
  50. --
  51. -- Struktura tabeli dla `news`
  52. --
  53.  
  54. CREATE TABLE `news` (
  55. `news_id` int(11) NOT NULL AUTO_INCREMENT,
  56. `heading` varchar(48) DEFAULT NULL,
  57. `body` text,
  58. `date` date DEFAULT NULL,
  59. `author_name` varchar(32) DEFAULT NULL,
  60. `author_email` varchar(64) DEFAULT NULL,
  61. PRIMARY KEY (`news_id`)
  62. ) TYPE=MyISAM AUTO_INCREMENT=1 ;
  63.  
  64. --
  65. -- Zrzut danych tabeli `news`
  66. --
  67.  
  68.  
  69. -- --------------------------------------------------------
  70.  
  71. --
  72. -- Struktura tabeli dla `news2`
  73. --
  74.  
  75. CREATE TABLE `news2` (
  76. `news_id` int(11) NOT NULL AUTO_INCREMENT,
  77. `title` varchar(32) DEFAULT NULL,
  78. `intro` text,
  79. `more` text,
  80. `author_id` int(11) DEFAULT NULL,
  81. `category_id` int(11) DEFAULT NULL,
  82. `date` date DEFAULT NULL,
  83. `time` time DEFAULT NULL,
  84. PRIMARY KEY (`news_id`)
  85. ) TYPE=MyISAM AUTO_INCREMENT=1 ;
  86.  
  87. --
  88. -- Zrzut danych tabeli `news2`
  89. --


czuje ze chodzi oto:
  1. <?php
  2. $cat_result = mysql_query("select categories.category from helpdesk, categories where helpdesk.categor
    y_id = categories.category_id and helpdesk.category_id = '$cat_num'"
    );
  3. ?>


Ten post edytował touse 12.01.2007, 11:58:09
Go to the top of the page
+Quote Post
maryaan
post 12.01.2007, 11:56:54
Post #4





Grupa: Zarejestrowani
Postów: 380
Pomógł: 2
Dołączył: 5.01.2007

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


a gdzie masz tabele helpdesk?
  1. <?php
  2. $cat_result = mysql_query("select categories.category from helpdesk, categories where helpdesk.categor
    y_id = categories.category_id and helpdesk.category_id = '$cat_num'"
    );
  3. ?>


--------------------
Wybierasz się do Zakopanego? Odwiedź Willę Pod Górami. Następnym razem na pewno do niej wrócisz :)
Go to the top of the page
+Quote Post
touse
post 12.01.2007, 12:01:57
Post #5





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 12.01.2007

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


a własnieeee czyli musialbym dodac nowa czy wystaczy zmienic nazwe ?
Go to the top of the page
+Quote Post
maryaan
post 12.01.2007, 12:12:03
Post #6





Grupa: Zarejestrowani
Postów: 380
Pomógł: 2
Dołączył: 5.01.2007

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


w helpdesk-u przchowujesz jak widac id kategorii ktore za pomoca ww zapytania jest "przerabiane" na nazwe kategorii, jesli id kategorii przechowujesz gdzie indziej to nalezy uwzglednic ta lokalizacj w zapytaniu, a jesli ten kod ma dzialac tak jak wymyslil to jego autor, to nalezy stworzyc tabele helpdesk


--------------------
Wybierasz się do Zakopanego? Odwiedź Willę Pod Górami. Następnym razem na pewno do niej wrócisz :)
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: 12.07.2025 - 21:41