(PHP MYSQL)Bug in my nav

  • Black_Legon
  • Beginner
  • Beginner
  • Black_Legon
  • Posts: 35
  • Loc: Netherlands

Post 3+ Months Ago

well... i have a script for my website that provides my page with a next and prev button...
But i get an error...:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\phpdev\www\phpwebsite_en\mlist1.php on line 67

Does anybody know how to solve this? :)
If tryed some things.. but none worked..

My script:
PHP Code: [ Select ]
 
<?
 
require("config.php");
 
 
 
echo "<link rel=\"stylesheet\" content=\"text/css\" href=\"atlantis.css\">";
 
 
 
if(!isset($start)) $start = 0;
 
 
 
if(!$mid){
 
 
 
$query = mysql_query("SELECT * FROM members LIMIT " . $start . ", 20");
 
$result = mysql_num_rows($query);
 
 
 
if(!$result){
 
echo "We hebben nog geen members...";
 
}
 
else{
 
echo "<table align=\"center\" border=\"1\" width=\"60%\" bordercolorlight=\"#003070\" cellspacing=\"0\" cellpadding=\"0\" bordercolordark=\"005090\" bordercolor=\"#005090\">\n";
 
echo    " <TR>\n";
 
echo    "  <TD width=\"60\">\n";
 
echo    "  <font class=\"red\">Nr:</font>\n";
 
echo    "  </TD>\n\n";
 
echo    "  <TD width=\"200\" height=\"30\" valign=\"center\">\n";
 
echo    "  <font class=\"red\">Username:</font>\n";
 
echo    "  </TD>\n\n";
 
echo    "  <TD>\n";
 
echo    "  <font class=\"red\">ID:</font>\n";
 
echo    "  </TD>\n\n";
 
echo    "  <TD>\n";
 
echo    "  <font class=\"red\">Points:</font>\n";
 
echo    "  </TD>\n";
 
echo    "  <TD Width=\"60\">\n";
 
echo  "  <font class=\"red\">Banned:</font>\n";
 
echo  "  </TD>\n";
 
echo    " </TR>\n\n";
 
 
 
$bgcounter = 1;
 
$nr1 = "0";
 
while($object = mysql_fetch_object($query)){
 
if($object->geactiveerd == 1){
 
   $ban = "No";
 
   } else {
 
  $ban = "Yes";
 
  }
 
 
 
 
 
$bgcounter++;
 
   if($bgcounter == 1){ $bg = "#004080";
 
   } else { $bg = "#003070"; $bgcounter=0; }
 
   
 
$nr1++;
 
 
 
echo    " <TR STYLE=\"background:$bg\">\n";
 
echo    "  <TD>($nr1)</TD>\n";
 
echo  "  <TD><a href=\"?mid=$object->memberid\">$object->gebruikersnaam</a></TD>\n";
 
echo    "  <TD>($object->memberid)</TD>\n";
 
echo    "  <TD><IMG SRC=\"image/points.jpg\">($object->points)</TD>\n";
 
echo  "  <TD>$ban</TD>\n";
 
echo    " </TR>\n\n";
 
 
 
}  
 
echo "</table>";
 
echo  "<br><font class=\"red\">Members that are banned will be removed after a month, or contact a admin.</font>";
 
}
 
 
 
$query = "SELECT count(*) as count FROM table";
 
$result = mysql_query($query);
 
$row = mysql_fetch_array($result);
 
$numrows = $row['count'];
 
if($start > 0)
 
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 20
 
) .
 
"\">Previous</a><BR>\n";
 
if($numrows > ($start + 20))
 
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 20
 
) .
 
"\">Next</a><BR>\n";
 
 
 
}
 
else{
 
$query = mysql_query("SELECT * FROM members WHERE memberid = '$mid'");
 
$result = mysql_num_rows($query);
 
 
 
if(!$result){
 
echo "This members does not exist...";
 
}
 
else{
 
mysql_query("UPDATE members SET bekeken = bekeken + 1 WHERE memberid = '$mid'");
 
while($object = mysql_fetch_object($query)){
 
?>
 
<br>
 
<b><font class="Red">UserName:</font></b><br>
 
<? echo $object->gebruikersnaam; ?>
 
<br><br>
 
<b><font class="Red">id:</font></b><br>
 
<? echo "#$object->memberid"; ?>
 
<br><br>
 
<b><Font class="Red">Points:</font></b><br>
 
<? echo "<IMG SRC=\"http://62.166.3.44/site/image/points.jpg\">($object->points)"; ?>
 
<br><br>
 
<b><Font class="Red">Country:</font></b><br>
 
<? echo $object->woonplaats; ?>
 
<?
 
}
 
}
 
}
 
?>
 
 
  1.  
  2. <?
  3.  
  4. require("config.php");
  5.  
  6.  
  7.  
  8. echo "<link rel=\"stylesheet\" content=\"text/css\" href=\"atlantis.css\">";
  9.  
  10.  
  11.  
  12. if(!isset($start)) $start = 0;
  13.  
  14.  
  15.  
  16. if(!$mid){
  17.  
  18.  
  19.  
  20. $query = mysql_query("SELECT * FROM members LIMIT " . $start . ", 20");
  21.  
  22. $result = mysql_num_rows($query);
  23.  
  24.  
  25.  
  26. if(!$result){
  27.  
  28. echo "We hebben nog geen members...";
  29.  
  30. }
  31.  
  32. else{
  33.  
  34. echo "<table align=\"center\" border=\"1\" width=\"60%\" bordercolorlight=\"#003070\" cellspacing=\"0\" cellpadding=\"0\" bordercolordark=\"005090\" bordercolor=\"#005090\">\n";
  35.  
  36. echo    " <TR>\n";
  37.  
  38. echo    "  <TD width=\"60\">\n";
  39.  
  40. echo    "  <font class=\"red\">Nr:</font>\n";
  41.  
  42. echo    "  </TD>\n\n";
  43.  
  44. echo    "  <TD width=\"200\" height=\"30\" valign=\"center\">\n";
  45.  
  46. echo    "  <font class=\"red\">Username:</font>\n";
  47.  
  48. echo    "  </TD>\n\n";
  49.  
  50. echo    "  <TD>\n";
  51.  
  52. echo    "  <font class=\"red\">ID:</font>\n";
  53.  
  54. echo    "  </TD>\n\n";
  55.  
  56. echo    "  <TD>\n";
  57.  
  58. echo    "  <font class=\"red\">Points:</font>\n";
  59.  
  60. echo    "  </TD>\n";
  61.  
  62. echo    "  <TD Width=\"60\">\n";
  63.  
  64. echo  "  <font class=\"red\">Banned:</font>\n";
  65.  
  66. echo  "  </TD>\n";
  67.  
  68. echo    " </TR>\n\n";
  69.  
  70.  
  71.  
  72. $bgcounter = 1;
  73.  
  74. $nr1 = "0";
  75.  
  76. while($object = mysql_fetch_object($query)){
  77.  
  78. if($object->geactiveerd == 1){
  79.  
  80.    $ban = "No";
  81.  
  82.    } else {
  83.  
  84.   $ban = "Yes";
  85.  
  86.   }
  87.  
  88.  
  89.  
  90.  
  91.  
  92. $bgcounter++;
  93.  
  94.    if($bgcounter == 1){ $bg = "#004080";
  95.  
  96.    } else { $bg = "#003070"; $bgcounter=0; }
  97.  
  98.    
  99.  
  100. $nr1++;
  101.  
  102.  
  103.  
  104. echo    " <TR STYLE=\"background:$bg\">\n";
  105.  
  106. echo    "  <TD>($nr1)</TD>\n";
  107.  
  108. echo  "  <TD><a href=\"?mid=$object->memberid\">$object->gebruikersnaam</a></TD>\n";
  109.  
  110. echo    "  <TD>($object->memberid)</TD>\n";
  111.  
  112. echo    "  <TD><IMG SRC=\"image/points.jpg\">($object->points)</TD>\n";
  113.  
  114. echo  "  <TD>$ban</TD>\n";
  115.  
  116. echo    " </TR>\n\n";
  117.  
  118.  
  119.  
  120. }  
  121.  
  122. echo "</table>";
  123.  
  124. echo  "<br><font class=\"red\">Members that are banned will be removed after a month, or contact a admin.</font>";
  125.  
  126. }
  127.  
  128.  
  129.  
  130. $query = "SELECT count(*) as count FROM table";
  131.  
  132. $result = mysql_query($query);
  133.  
  134. $row = mysql_fetch_array($result);
  135.  
  136. $numrows = $row['count'];
  137.  
  138. if($start > 0)
  139.  
  140. echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 20
  141.  
  142. ) .
  143.  
  144. "\">Previous</a><BR>\n";
  145.  
  146. if($numrows > ($start + 20))
  147.  
  148. echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 20
  149.  
  150. ) .
  151.  
  152. "\">Next</a><BR>\n";
  153.  
  154.  
  155.  
  156. }
  157.  
  158. else{
  159.  
  160. $query = mysql_query("SELECT * FROM members WHERE memberid = '$mid'");
  161.  
  162. $result = mysql_num_rows($query);
  163.  
  164.  
  165.  
  166. if(!$result){
  167.  
  168. echo "This members does not exist...";
  169.  
  170. }
  171.  
  172. else{
  173.  
  174. mysql_query("UPDATE members SET bekeken = bekeken + 1 WHERE memberid = '$mid'");
  175.  
  176. while($object = mysql_fetch_object($query)){
  177.  
  178. ?>
  179.  
  180. <br>
  181.  
  182. <b><font class="Red">UserName:</font></b><br>
  183.  
  184. <? echo $object->gebruikersnaam; ?>
  185.  
  186. <br><br>
  187.  
  188. <b><font class="Red">id:</font></b><br>
  189.  
  190. <? echo "#$object->memberid"; ?>
  191.  
  192. <br><br>
  193.  
  194. <b><Font class="Red">Points:</font></b><br>
  195.  
  196. <? echo "<IMG SRC=\"http://62.166.3.44/site/image/points.jpg\">($object->points)"; ?>
  197.  
  198. <br><br>
  199.  
  200. <b><Font class="Red">Country:</font></b><br>
  201.  
  202. <? echo $object->woonplaats; ?>
  203.  
  204. <?
  205.  
  206. }
  207.  
  208. }
  209.  
  210. }
  211.  
  212. ?>
  213.  
  214.  


where line 76 is:
PHP Code: [ Select ]
while($object = mysql_fetch_object($query)){


And the test page with te error is:
http://62.166.3.44/site/mlist1.php


Sorry for the big script...

Hope you can help me..

Grs.
Black_Legon
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Yea, I had a similar problem using the COUNT function in MySQL, I got around it some way, but do you have something like phpMyAdmin on your server so you can test the query more easily? That is how I did it, just went though a lot of different queries.
I'll try to find what I did, in the meantime just try what I said.

Another thing, did you mean to get the count function from `table`?
  • Black_Legon
  • Beginner
  • Beginner
  • Black_Legon
  • Posts: 35
  • Loc: Netherlands

Post 3+ Months Ago

I have mad from mysql_fetch_array => mysql_fetch_row

And it works fine now :S

Don't know why... but it works...

Tnx anyway for the time :)

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: Liamw411 and 47 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.