Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: [php+mysq] blad w skrypcie
Forum PHP.pl > Forum > Przedszkole
touse
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
kossa
Komunikat ten oznacza ¿e masz b³±d w zapytaniu SQL. Sparwdz nazwy tabel, kolumn.

£ukasz
touse
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. ?>
maryaan
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. ?>
touse
a w³asnieeee czyli musialbym dodac nowa czy wystaczy zmienic nazwe ?
maryaan
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
To jest wersja lo-fi g³ównej zawarto¶ci. Aby zobaczyæ pe³n± wersjê z wiêksz± zawarto¶ci±, obrazkami i formatowaniem proszê kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.