-3

将网站上传到我的网络服务器后,我收到以下消息:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource 
in /home1/m1k3ey/public_html/MikeyDev.com/teamdesire/playersheet.php on line 8

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource 
in /home1/m1k3ey/public_html/MikeyDev.com/teamdesire/playersheet.php on line 9

我的 PHP 版本是:

PHP Version 5.2.17

我看不到我的代码哪里出错了,任何人都可以帮忙:

          mysql_select_db('teamdesire', $link);
          $query = "SELECT * FROM playershowercase";
          $result = mysql_query($query,$link);
          $row = array();
Line 8 >  while($row[] = mysql_fetch_array($result));
Line 9 >  $count = mysql_num_rows($result);
          $random = rand(0,$count-1);
4

3 回答 3

0

也许像下面这样?

      mysql_select_db('teamdesire', $link);
      $query = "SELECT * FROM playershowercase";
      $result = mysql_query($query,$link);
      $row = mysql_fetch_assoc($result);
      $count = mysql_num_rows($result);
      $random = rand(0,$count-1);

或者

      mysql_select_db('teamdesire', $link);
      $query = "SELECT * FROM playershowercase";
      $result = mysql_query($query,$link);
      while ($row = mysql_fetch_array($result, MYSQL_NUM))
      $count = mysql_num_rows($result);
      $random = rand(0,$count-1);
于 2013-07-16T15:48:58.570 回答
0

可能的错误来源:

  • Db 未在指定的套接字或端口上运行。
  • 对表或数据库的权限不足。
  • 登录凭据不正确。
  • 表不存在或拼写错误。

故障排除时每行回显。

is_resource($link) or die('Could not connect');
mysql_query(...);
echo mysql_error();
于 2013-07-16T16:49:00.200 回答
-1

尝试这个:

          mysql_select_db('teamdesire', $link);
          $query = "SELECT * FROM playershowercase";
          $result = mysql_query($query,$link);
          $row = array();
          while($result = mysql_fetch_array($result))
          {
          $row[]=$result;
          }
          $count = mysql_num_rows($result);
          $random = rand(0,$count-1);
于 2013-07-16T15:30:28.697 回答