将网站上传到我的网络服务器后,我收到以下消息:
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);
答案 0 :(得分: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);
答案 1 :(得分:0)
可能的错误来源:
排除故障时每行的回音行。
is_resource($link) or die('Could not connect');
mysql_query(...);
echo mysql_error();
答案 2 :(得分:-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);