mysql_num_rows(): supplied argument is not a valid MySQL result resource

Reply

Join Date: Aug 2007
Posts: 1
Reputation: kaleidoscopelex is an unknown quantity at this point 
Solved Threads: 0
kaleidoscopelex kaleidoscopelex is offline Offline
Newbie Poster

mysql_num_rows(): supplied argument is not a valid MySQL result resource

 
0
  #1
Aug 14th, 2007
Im having these problems, it used to work in my website for almost a year then suddenly this error occured..

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/alexsl/public_html/admin/system/functions.php on line 291

here's functions.php:
  1. <?php
  2. // Somery, a weblogging script by Robin de Graaf, copyright 2001-2006
  3. // Somery is distributed under the Artistic License (see LICENSE.txt)
  4. //
  5. // ADMIN/SYSTEM/FUNCTIONS.PHP > 08-03-2006
  6.  
  7. // execute some stuff
  8. extract($_POST);
  9. extract($_GET);
  10. mysql_connect($sqlhost, $sqluser, $sqlpass);
  11. mysql_select_db($sqldb);
  12. skinset();
  13. loaduser();
  14.  
  15. $localver = "0.4.6";
  16.  
  17. // functions for the admin system, gathering data
  18. function format_date($raw_date, $format="Y-m-d H:i:s",$tz) {
  19. global $prefix, $settings;
  20. ereg("(....)-(..)-(..) (..):(..):(..)",$raw_date,$reg);
  21. return date($format, mktime($reg[4],$reg[5],$reg[6],$reg[2],$reg[3],$reg[1])+($tz*3600));
  22. }
  23.  
  24. function whitelist($word) {
  25. global $prefix;
  26. if ($word) {
  27. $result = mysql_query("SELECT * FROM ".$prefix."additionals WHERE calltitle = '$word'");
  28. $total = mysql_num_rows($result);
  29. if ($total == 0) {
  30. return 0;
  31. } else {
  32. return 1;
  33. }
  34. } else {
  35. return 0;
  36. }
  37. }
  38.  
  39. function skinset() {
  40. global $prefix, $skindir;
  41. $result = mysql_query("SELECT * FROM ".$prefix."settings");
  42. while($row=mysql_fetch_object($result)) {
  43. $skindir = $row->skindir;
  44. }
  45. $skindir = "skins/".$skindir;
  46. return;
  47. }
  48.  
  49. function loadsettings() {
  50. global $prefix, $settings;
  51. $result = mysql_query("SELECT * FROM ".$prefix."settings");
  52. while($row=mysql_fetch_object($result)) {
  53. $settings['setskin'] = $row->skindir;
  54. $settings['startlevel'] = $row->startlevel;
  55. $settings['gmt'] = $row->gmt;
  56. $settings['dateformat'] = $row->dateformat;
  57. $settings['timeformat'] = $row->timeformat;
  58. $settings['startstatus'] = $row->startstatus;
  59. $settings['registration'] = $row->registration;
  60. $settings['comments'] = $row->comments;
  61. $settings['noposts'] = $row->noposts;
  62. $settings['archive'] = $row->archive;
  63. $settings['more'] = $row->more;
  64. $settings['nocomments'] = $row->nocomments;
  65. }
  66. return;
  67. }
  68.  
  69. function loaduser($username="") {
  70. global $userdata, $prefix;
  71. if ($username) {
  72. $result = mysql_query("SELECT * FROM ".$prefix."users WHERE username = '$username'");
  73. while($row=mysql_fetch_object($result)) {
  74. $userdata['username'] = $row->username;
  75. $userdata['password'] = $row->password;
  76. $userdata['level'] = $row->level;
  77. }
  78. }
  79. return $userdata;
  80. }
  81.  
  82. function loadprofile($username="",$profile) {
  83. global $prefix;
  84. if ($username && $profile) {
  85. $result = mysql_query("SELECT $profile FROM ".$prefix."profile WHERE username = '$username'");
  86. while($row=mysql_fetch_object($result)) {
  87. $text = $row->$profile;
  88. }
  89. }
  90. return $text;
  91. }
  92.  
  93. // functions for the skin system
  94. function menu() {
  95. global $checkauth,$prefix,$userdata;
  96. if ($checkauth) {
  97. echo "<a href='index.php'>index</a> - ";
  98. echo "<a href='profile.php'>profile</a> - ";
  99. echo "<a href='notes.php'>notes</a> - ";
  100. if ($userdata['level'] >= 1) echo "<a href='articles.php'>articles</a> - ";
  101. echo "<a href='team.php'>team</a> - ";
  102. if ($userdata['level'] >= 3) echo "<a href='additionals.php'>additionals</a> - ";
  103. if ($userdata['level'] >= 3) echo "<a href='settings.php'>settings</a> - ";
  104. if ($userdata['level'] >= 2) echo "<a href='categories.php'>categories</a> - ";
  105. echo "<a href='login.php?a=logout'>logout</a> ";
  106. } elseif (!$checkauth) {
  107. $result = mysql_query("SELECT * FROM ".$prefix."settings");
  108. while($row=mysql_fetch_object($result)) {
  109. $settings['registration'] = $row->registration;
  110. }
  111. if ($settings['registration'] == 0) echo "you're not logged in";
  112. if ($settings['registration'] == 1) echo "<a href='register.php'>register</a>";
  113. }
  114. }
  115.  
  116. // functions for formatting
  117. function debbcode($text) {
  118. $text = ereg_replace("\[b\]|\[/b\]|\[i\]|\[/i\]|\[u\]|\[/u\]|\[img\]|\[/img\]|\[quote\]|\[/quote\]|\[email\]|\[/email\]|\[url\]|\[/url\]","", $text);
  119. return $text;
  120. }
  121.  
  122. function bbcode($text,$type=0) {
  123. $text = ereg_replace("\r\r", "</p><p>", $text);
  124. $text = ereg_replace("\r\n\r\n", "</p><p>", $text);
  125. $text = ereg_replace("\n\n", "</p><p>", $text);
  126. $text = ereg_replace("\n", "<br />", $text);
  127.  
  128. $text = preg_replace("/\[quote\](.+?)\[\/quote\]/is", "<blockquote><b>Quote:</b><br />\\1</blockquote>", $text);
  129. $text = preg_replace("/\[center\](.+?)\[\/center\]/is", "</p><center>\\1</center><p>", $text);
  130. $text = preg_replace("/\[b\](.+?)\[\/b\]/is", "<b>\\1</b>", $text);
  131. $text = preg_replace("/\[i\](.+?)\[\/i\]/is", "<i>\\1</i>", $text);
  132. $text = preg_replace("/\[u\](.+?)\[\/u\]/is", "<u>\\1</u>", $text);
  133. if ($type != 1) $text = preg_replace("/\[img\](.+?)\[\/img\]{1}/is", "<img src='\\1' border='0' alt=''>", $text);
  134. $text = preg_replace("/\[email\](.+?)\[\/email\]{1}/is", "<a href='mailto:\\1'>\\1</a>", $text);
  135.  
  136. $text = preg_replace("/\[url=([^<]+?)\](.+?)\[\/url\]{1}/is", "<a href='\\1'>\\2</a>", $text);
  137. $text = preg_replace("/\[url\](.+?)\[\/url\]{1}/is", "<a href='\\1'>\\1</a>", $text);
  138. $text = preg_replace("/\[newurl=([^<]+?)\](.+?)\[\/newurl\]{1}/is", "<a href='\\1' target='_blank'>\\2</a>", $text);
  139. $text = preg_replace("/\[newurl\](.+?)\[\/newurl\]{1}/is", "<a href='\\1' target='_blank'>\\1</a>", $text);
  140. return $text;
  141. }
  142.  
  143. function cleanstring($text) {
  144. $text = ereg_replace("[\x27]","'",trim($text));
  145. $text = ereg_replace("[\x22]","&quot;",trim($text));
  146. strip_tags($text);
  147. $text = ereg_replace(">","&gt;",$text);
  148. $text = ereg_replace("<","&lt;",$text);
  149. $text = preg_replace("[\x5c\]","",$text);
  150. return $text;
  151. }
  152.  
  153. // functions for the output engine
  154. function archive($output="%",$type="title",$dtype="d/m/Y") {
  155. global $total,$arow,$prefix,$p,$settings,$PHP_SELF;
  156. if ($settings['archive'] != "0") { $limit = " LIMIT ".$settings['archive']; }
  157. $result = mysql_query("SELECT * FROM ".$prefix."articles WHERE status = '1' ORDER BY aid DESC$limit");
  158. while($row=mysql_fetch_object($result)) {
  159. if ($type == "date") $more = "<a href='".$PHP_SELF."?p=".$row->aid."&c=1'>".debbcode(date($dtype,strtotime($row->date)))."</a>";
  160. if ($type == "title") $more = "<a href='".$PHP_SELF."?p=".$row->aid."&c=1'>".debbcode($row->title)."</a>";
  161. if ($type == "td") $more = "<a href='".$PHP_SELF."?p=".$row->aid."&c=1'>".debbcode(date($dtype,strtotime($row->date)))." - ".strtolower(debbcode($row->title))."</a>";
  162. $info=eregi_replace("\%",$more,$output);
  163. echo $info;
  164. }
  165. if (!$result) echo "empty";
  166. }
  167.  
  168. function exportadd($word,$type="body",$dtype="d/m/Y H:i") {
  169. global $prefix, $settings;
  170. $result = mysql_query("SELECT * FROM ".$prefix."additionals WHERE calltitle = '$word'");
  171. while($row=mysql_fetch_object($result)) {
  172. if ($type == "body") {
  173. $body = cleanstring($row->body);
  174. $body = bbcode($body);
  175. echo $body;
  176. } elseif ($type == "title") {
  177. $body = cleanstring($row->title);
  178. $body = bbcode($body);
  179. echo $body;
  180. } elseif ($type == "calltitle") {
  181. $body = cleanstring($row->calltitle);
  182. $body = bbcode($body);
  183. echo $body;
  184. } elseif ($type == "created") {
  185. $body = format_date($row->created, $settings['dateformat']." ".$settings['timeformat'], $settings['gmt']);
  186. echo $body;
  187. } elseif ($type == "modified") {
  188. $body = format_date($row->modified, $settings['dateformat']." ".$settings['timeformat'], $settings['gmt']);
  189. echo $body;
  190. }
  191. }
  192. }
  193.  
  194. function prevnext($next="newer posts",$divider=" - ",$previous="older posts") {
  195. global $total,$arow,$prefix,$p,$settings,$PHP_SELF,$offset;
  196.  
  197. if (!$offset) { $offset = 0; }
  198.  
  199. $offsetnext = $offset - $settings['noposts'];
  200. $offsetprev = $offset + $settings['noposts'];
  201.  
  202. if ($offsetnext < 0) {
  203. $next = "no newer posts";
  204. } else {
  205. $next = "<a href='index.php?offset=$offsetnext'>$next</a>";
  206. }
  207.  
  208. $resultz = mysql_query("SELECT * FROM ".$prefix."articles WHERE status = '1'");
  209. $totalz = mysql_num_rows($resultz);
  210.  
  211. $change = $totalz - $settings['noposts'];
  212.  
  213. if ($offset >= $change) {
  214. $prev = "no older posts";
  215. } else {
  216. $prev = "<a href='index.php?offset=$offsetprev'>$previous</a>";
  217. }
  218.  
  219. echo $next.$divider.$prev;
  220. }
  221.  
  222. function getauthor($item) {
  223. global $settings, $row, $prefix;
  224. $result2 = mysql_query("SELECT * FROM ".$prefix."profile WHERE username = '".$row->username."'");
  225. while($row2=mysql_fetch_object($result2)) {
  226. echo $row2->$item;
  227. }
  228. }
  229.  
  230. function getadate() {
  231. global $row, $prefix, $settings;
  232. echo format_date($row->datetime, $settings['dateformat'], $settings['gmt']);
  233. }
  234.  
  235. function getatime() {
  236. global $row, $prefix, $settings;
  237. echo format_date($row->datetime, $settings['timeformat'], $settings['gmt']);
  238. }
  239.  
  240. function permalink() {
  241. global $settings, $row, $prefix, $PHP_SELF;
  242. echo "<a href=\"$PHP_SELF?p=$row->aid&amp;c=1\">$row->title</a>";
  243. }
  244.  
  245. function body() {
  246. global $settings, $row, $prefix, $p, $PHP_SELF;
  247. $body = cleanstring($row->body);
  248. $body = bbcode($body);
  249. if (!$p) {
  250. echo $body."</p>";
  251. } elseif ($p && $row->show_body == 1) {
  252. echo $body."</p>";
  253. }
  254. if ($row->more && !$p) {
  255. echo "<p><a href=\"$PHP_SELF?p=$row->aid&amp;c=1\">".$settings[more]."</a></p>";
  256. } elseif ($row->more && $p) {
  257. $more = cleanstring($row->more);
  258. $more = bbcode($more);
  259. echo "<p>".$more."</p>";
  260. }
  261. }
  262.  
  263. function commentlink ($none="no comment",$single="1 comment",$more="% comments") {
  264. global $row, $prefix, $settings, $PHP_SELF;
  265. if ($settings[comments] == 1 && $row->show_comments == 1) {
  266. $count = mysql_query("SELECT * FROM ".$prefix."comments WHERE parentid = $row->aid");
  267. $total = mysql_num_rows($count);
  268. if ($total == 0) echo "<a href=\"$PHP_SELF?p=$row->aid&amp;c=1#comments\">$none</a>";
  269. if ($total == 1) echo "<a href=\"$PHP_SELF?p=$row->aid&amp;c=1#comments\">$single</a>";
  270. if ($total > 1) {
  271. $t="$total";
  272. $more=eregi_replace("\%",$t,$more);
  273. echo "<a href=\"$PHP_SELF?p=$row->aid&amp;c=1#comments\">$more</a>";
  274. }
  275. } else {
  276. echo $settings[nocomments];
  277. }
  278. }
  279.  
  280. function getarticle($item) {
  281. global $settings, $row, $prefix;
  282. $result2 = mysql_query("SELECT * FROM ".$prefix."articles WHERE aid = '".$row->aid."'");
  283. while($row2=mysql_fetch_object($result2)) {
  284. echo $row2->$item;
  285. }
  286. }
  287.  
  288. function getcomment($item) {
  289. global $settings, $c_row, $prefix, $dtr;
  290. $result2 = mysql_query("SELECT * FROM ".$prefix."comments WHERE coid = '".$c_row->coid."'");
  291. while($row2=mysql_fetch_object($result2)) {
  292. if ($item == "date") {
  293. echo format_date($row2->datetime, "d/m/Y", $settings['gmt']);
  294. }
  295. if ($item == "time") {
  296. echo format_date($row2->datetime, "H:i", $settings['gmt']);
  297. }
  298. if ($item != "date" && $item != "time") echo $row2->$item;
  299. }
  300. }
  301.  
  302. function category () {
  303. global $row, $prefix;
  304. $result2 = mysql_query("SELECT * FROM ".$prefix."categories WHERE cid = '".$row->category."'");
  305. while($row2=mysql_fetch_object($result2)) {
  306. echo $row2->category;
  307. }
  308. }
  309.  
  310. function catlink () {
  311. global $row, $PHP_SELF;
  312. echo "$PHP_SELF?cat=$row->category";
  313. }
  314.  
  315. function userlink () {
  316. global $row, $PHP_SELF;
  317. echo "$PHP_SELF?user=$row->username";
  318. }
  319.  
  320. function comment() {
  321. global $settings, $c_row, $prefix, $p;
  322. $result2 = mysql_query("SELECT * FROM ".$prefix."comments WHERE coid = '".$c_row->coid."'");
  323. while($row2=mysql_fetch_object($result2)) {
  324. $comment = cleanstring($row2->comment);
  325. $comment = bbcode($comment,1);
  326. echo $comment;
  327. }
  328. }
  329.  
  330. ?>
==============================================
AND HERE'S THE OTHER ONE...

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/alexsl/public_html/admin/articles.php on line 47

here's article.php:
  1. <?php
  2. // Somery, a weblogging script by Robin de Graaf, copyright 2001-2006
  3. // Somery is distributed under the Artistic License (see LICENSE.txt)
  4. //
  5. // ADMIN/ARTICLES.PHP > 08-03-2006
  6.  
  7. $start = TRUE;
  8. include("system/include.php");
  9. if ($checkauth) {
  10.  
  11. loadsettings();
  12.  
  13. if ($userdata['level'] >= 1) {
  14.  
  15. if (!$action) {
  16. ?>
  17. <a name='top'></a>
  18. <strong>Add a new article - <a href="articles.php#active">Active articles</a>/<a href="articles.php#hidden">Hidden articles</a></strong><br />
  19. <table><tr><td><form method="post" action="articles.php"><input type="hidden" name="action" value="post"></td></tr></table>
  20. <table>
  21. <tr><td width=175>Author</td><td><?php echo $user; ?></td></tr>
  22. <tr><td width=175>Article title</td><td><input size=50 name='title' type='text'></td></tr>
  23. <tr><td width=175>Post in category</td><td><select name='category'>
  24. <?php
  25. $query = "SELECT * FROM ".$prefix."categories ORDER BY cid";
  26. $result = mysql_query($query);while($row=mysql_fetch_object($result)) {
  27. echo "<option value='$row->cid'>$row->category";
  28. } ?>
  29. </select></td></tr>
  30. <tr><td width=175 valign=top>Article body</td><td><textarea name='body' rows=12 cols=50></textarea></td></tr>
  31. <tr><td width=175 valign=top>Article more</td><td><textarea name='more' rows=12 cols=50></textarea></td></tr>
  32. <tr><td width=175>Show body after more</td><td><input type='checkbox' name='showbody' CHECKED></td></tr>
  33. <tr><td width=175>Enable comments</td><td><input type='checkbox' name='comments' CHECKED></td></tr>
  34. <?php
  35. if ($settings[startstatus] == 1) $d = " CHECKED";
  36. ?>
  37. <tr><td width=175>Article visible<br><br></td><td><input type='checkbox' name='status'<?php echo $d; ?>><br><br></td></tr>
  38. <tr><td width=175>Save changes</td><td><input type='submit' value='proceed'></td></tr>
  39. </table><br>
  40. <?php
  41.  
  42. $result = mysql_query("SELECT * FROM ".$prefix."articles WHERE status = '1' ORDER BY aid DESC");
  43. $total = mysql_num_rows($result);
  44. echo "<a name='active'></a><table width=\"100%\"><tr><td colspan=\"2\"><b>Active articles (".$total.") - <a href='articles.php#top'>Back to top</a></b></td></tr>";
  45. while($row=mysql_fetch_object($result)) {
  46. $resultc = mysql_query("SELECT * FROM ".$prefix."comments WHERE parentid = '".$row->aid."'");
  47. $totalc = mysql_num_rows($resultc);
  48.  
  49. echo "<tr><td>";
  50. if ($user == $row->username || $userdata['level'] >= 3) {
  51. echo "<a href='articles.php?action=edit&aid=$row->aid'>".debbcode($row->title)."</a>";
  52. } else {
  53. echo debbcode($row->title);
  54. }
  55. echo " by ".$row->username." (<a href='articles.php?action=comview&aid=$row->aid'>comments: ".$totalc."</a>)</td><td width=\"75\">";
  56. getadate();
  57. echo "</tr>";
  58. }
  59. if (!$total) echo "<tr><td width=100%>None</td></tr>";
  60. echo "</table><br>";
  61.  
  62. $result = mysql_query("SELECT * FROM ".$prefix."articles WHERE status = '0' ORDER BY aid DESC");
  63. $total = mysql_num_rows($result);
  64. echo "<a name='hidden'></a><table><tr><td><b>Hidden articles (".$total.") - <a href='articles.php#top'>Back to top</a></b></td></tr>";
  65. while($row=mysql_fetch_object($result)) {
  66. $resultc = mysql_query("SELECT * FROM ".$prefix."comments WHERE parentid = '".$row->aid."'");
  67. $totalc = mysql_num_rows($resultc);
  68.  
  69. echo "<tr><td width=100%><a href='articles.php?action=edit&aid=$row->aid'>".debbcode($row->title)."</a> by ".$row->username." (<a href='articles.php?action=comview&aid=$row->aid'>comments: ".$totalc."</a>)</td></tr>";
  70. }
  71. if (!$total) echo "<tr><td width=100%>None</td></tr>";
  72. echo "</table>";
  73. } elseif ($action == "post") {
  74. $title = debbcode($title);
  75. $title = cleanstring($title);
  76. $body = cleanstring($body);
  77. $more = cleanstring($more);
  78. $body = addslashes($body);
  79. $more = addslashes($more);
  80. if ($showbody) { $showbody = 1; } else { $showbody = 0; }
  81. if ($comments) { $comments = 1; } else { $comments = 0; }
  82. if ($status) { $status = 1; } else { $status = 0; }
  83.  
  84. if (!$title && !$err) { echo $error[11]; $err = 1; }
  85. if (!$body && !$err) { echo $error[12]; $err = 1; }
  86.  
  87. if (!$err) {
  88. $result = mysql_query("INSERT INTO ".$prefix."articles (username,title,body,more,category,datetime,status,show_comments,show_body) VALUES ('".$userdata['username']."','$title','$body','$more','$category','".date("Y-m-d H:i:s")."','$status','$comments','$showbody')");
  89. echo "Article posted, redirecting...<meta http-equiv=Refresh content=1;URL='articles.php'>";
  90. }
  91. } elseif ($action == "edit") {
  92. $result = mysql_query("SELECT * FROM ".$prefix."articles WHERE aid = '$aid'");
  93. while($row=mysql_fetch_object($result)) {
  94. if ($user == $row->username || $userdata['level'] >= 3) {
  95.  
  96. if ($row->status) $status = " CHECKED";
  97. if ($row->show_comments) $comments = " CHECKED";
  98. if ($row->show_body) $showbody = " CHECKED";
  99. ?>
  100. <b>Edit an article</b><br>
  101. <table><tr><td><form method="post" action="articles.php"><input type="hidden" name="action" value="update"><input type="hidden" name="aid" value="<?php echo $aid;?>"></td></tr></table>
  102. <table>
  103. <tr><td width=175>Article title</td><td><input size=50 name='title' type='text' value='<?php echo $row->title;?>'></td></tr>
  104. <tr><td width=175>Post in category</td><td><select name='category'>
  105. <?php
  106. $resultcat = mysql_query("SELECT * FROM ".$prefix."categories ORDER BY cid");while($rowc=mysql_fetch_object($resultcat)) {
  107. if ($rowc->cid == $row->category) {
  108. echo "<option value='$rowc->cid' SELECTED>$rowc->category";
  109. } else {
  110. echo "<option value='$rowc->cid'>$rowc->category";
  111. }
  112. } ?>
  113. </select></td></tr>
  114. <tr><td width=175 valign=top>Article body</td><td><textarea name='body' rows=9 cols=50><?php echo $row->body;?></textarea></td></tr>
  115. <tr><td width=175 valign=top>Article more</td><td><textarea name='more' rows=9 cols=50><?php echo $row->more;?></textarea></td></tr>
  116. <tr><td width=175>Show body when using more</td><td><input type='checkbox' name='showbody'<?php echo $showbody;?>></td></tr>
  117. <tr><td width=175>Enable comments</td><td><input type='checkbox' name='comments'<?php echo $comments;?>></td></tr>
  118. <tr><td width=175>Article visible after editing</td><td><input type='checkbox' name='status'<?php echo $status;?>></td></tr>
  119. <tr><td width=175><br>Delete this post</td><td><br><input type='checkbox' name='delete'></td></tr>
  120. <tr><td width=175>Save changes</td><td><input type='submit' value='proceed'></td></tr>
  121. </table><br>
  122. <?php
  123. } else { echo "You're not allowed to do that"; }
  124. }
  125. } elseif ($action == "update") {
  126. if ($delete) {
  127. $result = mysql_query("DELETE FROM ".$prefix."articles WHERE aid = '$aid'");
  128. $result = mysql_query("DELETE FROM ".$prefix."comments WHERE parentid = '$aid'");
  129. echo "Article and comments deleted, redirecting...<meta http-equiv=Refresh content=1;URL='articles.php'>";
  130. $err = 1;
  131. } else {
  132. $title = debbcode($title);
  133. $title = cleanstring($title);
  134. $body = cleanstring($body);
  135. $more = cleanstring($more);
  136. if ($showbody) { $showbody = 1; } else { $showbody = 0; }
  137. if ($comments) { $comments = 1; } else { $comments = 0; }
  138. if ($status) { $status = 1; } else { $status = 0; }
  139.  
  140. if (!$title && !$err) { echo $error[11]; $err = 1; }
  141. if (!$body && !$err) { echo $error[12]; $err = 1; }
  142.  
  143. if (!$err) {
  144. $result = mysql_query("UPDATE ".$prefix."articles SET
  145. title='$title',
  146. body='$body',
  147. more='$more',
  148. category='$category',
  149. status='$status',
  150. show_comments='$comments',
  151. show_body='$showbody'
  152. WHERE aid = '$aid'");
  153. echo "Article updated, redirecting...<meta http-equiv=Refresh content=1;URL='articles.php'>";
  154. }
  155. }
  156. } elseif ($action == "comview") {
  157. $result = mysql_query("SELECT * FROM ".$prefix."comments WHERE parentid = '".$aid."'");
  158. $total = mysql_num_rows($result);
  159. echo "<b>view comments ($total)</b><br><br>";
  160. $result = mysql_query("SELECT * FROM ".$prefix."comments WHERE parentid = '".$aid."' ORDER BY coid");
  161. while($row=mysql_fetch_object($result)) {
  162. echo "<b><a href='mailto:$row->email'>$row->author</a></b> - <a href='articles.php?action=comedit&coid=$row->coid'>edit</a> - ";
  163. getadate();
  164. echo " - ";
  165. getatime();
  166. echo "<br />$row->comment<br><br />";
  167. }
  168. echo "<table><tr><td><form method='post' action='articles.php'><input type='hidden' name='action' value='compost'><input type='hidden' name='aid' value='$aid'></td></tr></table>
  169. <table>
  170. <tr><td width=175 valign=top>Author</td><td><input size=30 name='author' type='text' value='".loadprofile($user,"nickname")."'></td></tr>
  171. <tr><td width=175 valign=top>Author email</td><td><input size=30 name='email' type='text' value='".loadprofile($user,"email")."'></td></tr>
  172. <tr><td width=175 valign=top>Author url</td><td><input size=30 name='url' type='text' value='".loadprofile($user,"url")."'></td></tr>
  173. <tr><td width=175 valign=top>Author comment</td><td><textarea name='comment' rows=9 cols=29>$row->comment</textarea></td></tr>
  174. <tr><td width=175>Save changes</td><td><input type='submit' value='proceed'></td></tr></table>";
  175. } elseif ($action == "comedit") {
  176. echo "<b>edit comment</b><br>";
  177. $result = mysql_query("SELECT * FROM ".$prefix."comments WHERE coid = '".$coid."'");
  178. echo "<table><tr><td><form method='post' action='articles.php'><input type='hidden' name='action' value='comupdate'><input type='hidden' name='coid' value='$coid'></td></tr></table>
  179. <table>";
  180. while($row=mysql_fetch_object($result)) {
  181. echo "
  182. <tr><td width=175 valign=top>Author</td><td><input size=30 name='author' type='text' value='$row->author'></td></tr>
  183. <tr><td width=175 valign=top>Author email</td><td><input size=30 name='email' type='text' value='$row->email'></td></tr>
  184. <tr><td width=175 valign=top>Author url</td><td><input size=30 name='url' type='text' value='$row->url'></td></tr>
  185. <tr><td width=175 valign=top>Author comment</td><td><textarea name='comment' rows=9 cols=29>$row->comment</textarea></td></tr>
  186. <tr><td width=175><br>Delete this post</td><td><br><input type='checkbox' name='delete'></td></tr>
  187. <tr><td width=175>save changes</td><td><input type='submit' value='proceed'></td></tr>";
  188. }
  189. echo "</table>";
  190. } elseif ($action == "comupdate") {
  191. $result = mysql_query("SELECT * FROM ".$prefix."comments WHERE coid = '$coid'");
  192. while($row=mysql_fetch_object($result)) {
  193. $aid = $row->parentid;
  194. }
  195. if ($delete) {
  196. $result = mysql_query("DELETE FROM ".$prefix."comments WHERE coid = '$coid'");
  197. echo "Comment deleted, redirecting...<meta http-equiv=Refresh content=1;URL='articles.php?action=comview&aid=$aid'>";
  198. $err = 1;
  199. } else {
  200. $author = debbcode($author);
  201. $author = cleanstring($author);
  202. $email = debbcode($email);
  203. $email = cleanstring($email);
  204. $url = debbcode($url);
  205. $url = cleanstring($url);
  206. $comment = cleanstring($comment);
  207. if (!$author && !$err) { echo $error[15]; $err = 1; }
  208. if (!$comment && !$err) { echo $error[16]; $err = 1; }
  209.  
  210. if (!$err) {
  211. $result = mysql_query("UPDATE ".$prefix."comments SET
  212. author='$author',
  213. email='$email',
  214. url='$url',
  215. comment='$comment'
  216. WHERE coid = '$coid'");
  217. echo "Comment updated, redirecting...<meta http-equiv=Refresh content=1;URL='articles.php?action=comview&aid=$aid'>";
  218. }
  219. }
  220. } elseif ($action == "compost") {
  221. $author = debbcode($author);
  222. $author = cleanstring($author);
  223. $email = debbcode($email);
  224. $email = cleanstring($email);
  225. $url = debbcode($url);
  226. $url = cleanstring($url);
  227. $comment = cleanstring($comment);
  228.  
  229. if (!$author && !$err) { echo $error[15]; $err = 1; }
  230. if (!$comment && !$err) { echo $error[16]; $err = 1; }
  231.  
  232. if (!$err) {
  233. $result = mysql_query("INSERT INTO ".$prefix."comments (parentid,author,email,url,comment,datetime) VALUES ('$aid','$author','$email','$url','$comment','".date("Y-m-d H:i:s")."')");
  234. echo "Comment posted, redirecting...<meta http-equiv=Refresh content=1;URL='articles.php?action=comview&aid=$aid'>";
  235. }
  236. }
  237. } ?>
  238. <?php }; $start = FALSE; include("system/include.php"); ?>

how do i solve these? please help.

thank you.
Last edited by cscgal; Aug 18th, 2007 at 3:40 pm. Reason: please use code tags
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: mysql_num_rows(): supplied argument is not a valid MySQL result resource

 
0
  #2
Aug 15th, 2007
That most likely means your query failed. Use mysql_error() to get the error message from mysql.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC