Jump to content

warning mysql_fetch_array


thegod

Recommended Posts

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in tops.php on line 33

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in tops.php on line 56

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in tops.php on line 76

 

 

i have point the lines out in red

this is tops coding

 

 

<?

session_start();

include "includes/functions.php";

logincheck();

$username=$_SESSION['username'];

include "includes/db_connect.php";

echo "$style";

 

?>

 

 

 

 

<center><html><head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

 

<body>

<table width="100%" border="0" cellspacing="4" cellpadding="2">

  <tr>

    <td width="274" height="122" valign="top"><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="<?php echo "$td_border"; ?>" bgcolor="#666666">

        <tr>

          <td height="22" colspan="2" background="includes/grad.jpg"><center class="TableHeading">

              <font color="#FFFFFF">Top 10 Ranks </center></td>

        </tr>

        <tr>

          <td width="127" height="10" valign="top"><b>Username</b></td>

          <td width="136" valign="top"><b>Rank</b></td>

        </tr>

        <center><?php

$tsel = mysql_query("select * from `users` where `userlevel`='0' and `status`='alive' order by `rank` desc limit 10");

while ($top=mysql_fetch_array($tsel)) { line 36

print "<tr><td></center><a href=profile.php?viewuser=$top[username]>$top[username]</a></td><td align=right>$top[rank]</td></tr>";

}

?>

  </table>

 

<br>

<br>

 

      <table width="100%" border="0" cellspacing="2" cellpadding="0" align="center">

  <tr>

    <td width="200%" height="122" valign="top"><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="<?php echo "$td_border"; ?>" bgcolor="#666666">

        <tr>

          <td height="22" colspan="2" background="includes/grad.jpg"><center class="TableHeading">

              <font color="#FFFFFF">10 Richest Players </center></td>

        </tr>

        <tr>

          <td width="127" height="10" valign="top"><b>Username</b></td>

          <td width="136" valign="top"><b>Rank</b></td>

        </tr>

       

        <?php

$tsel = mysql_query("select * from `users` where `userlevel`='0' and `status`='alive' order by `money` desc limit 10");

while ($top = mysql_fetch_array($tsel)) { Line 56

print "<tr><td><a href=profile.php?viewuser=$top[username]>$top[username]</a></td><td align=right>$top[rank]</td></</tr>";

}

?>

      </table>

 

 

<table width="100%" border="0" cellspacing="4" cellpadding="2">

  <tr>

    <td width="274" height="122" valign="top"><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="<?php echo "$td_border"; ?>" bgcolor="#666666">

        <tr>

          <td height="22" colspan="2" background="includes/grad.jpg"><center class="TableHeading">

              <font color="#FFFFFF">Top 10 Forum Posters </center></td>

        </tr>

        <tr>

          <td width="127" height="10" valign="top"><b>Username</b></td>

          <td width="136" valign="top"><b>Posts</b></td>

        </tr>

        <center><?php

$tsel = mysql_query("select * from `users` where `userlevel`='0' and `status`='alive' order by `posts` desc limit 10");

while ($top = mysql_fetch_array($tsel)) {  line 76

print "<tr><td></center><a href=profile.php?viewuser=$top[username]>$top[username]</a></td><td align=right>$top[posts]</td></tr>";

}

?>

  </table>

 

<br>

<br>

 

 

 

</td>

   

</table>

</body>

</html></center>

Link to comment
https://forums.phpfreaks.com/topic/53529-warning-mysql_fetch_array/
Share on other sites

Change this line:

 

<?php
   $tsel = mysql_query("select * from `users` where `userlevel`='0' and `status`='alive' order by `rank` desc limit 10");
while ($top=mysql_fetch_array($tsel)) { // line 36
      print "<tr><td></center><a href=profile.php?viewuser=$top[username]>$top[username][/url]</td><td align=right>$top[rank]</td></tr>";
   }
   ?>

 

To this:

<?php
   $tsel = mysql_query($query = "select * from `users` where `userlevel`='0' and `status`='alive' order by `rank` desc limit 10") or trigger_error(mysql_error()."<PRE>".$query."</PRE>", E_USER_ERROR);;
while ($top=mysql_fetch_array($tsel)) { // line 36
      print "<tr><td></center><a href=profile.php?viewuser=$top[username]>$top[username][/url]</td><td align=right>$top[rank]</td></tr>";
   }
   ?>

 

... and investigate the mysql error.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.