日期:2014-05-17  浏览次数:20448 次

数据读取错误
conn.php
<?php
$conn=mysql_connect("localhost","mlstudio","ml902975");
mysql_select_db("db_bcty365",$conn);
mysql_query("set names gb2312");
?>

显示页面代码
 
  <table width="220" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <td>
<table width="220" height="260" class="b">
  <tr valign="top">
  <td height="38" bgcolor="#FFFFFF">
<table width="200" height="22" border="0" align="center" cellpadding="0" cellspacing="0">
  <?php
$sqluwz=mysql_query("select * from tb_soft order by addtime desc limit 0,7",$conn);
$infouwz=mysql_fetch_array($sqluwz);
if($infouwz==false){ 
?>
  <tr>
  <td width="20" height="22"><div align="center"><img src="images/mark_0.gif" width="3" height="3" /></div></td>
  <td width="180">&nbsp;暂无软件提供下载!</td>
  </tr>
  <?php
}else{
$i=1;
do{  
?>
  <tr>
  <td width="20" height="22"><div align="center"><img src="images/mark_0.gif" width="3" height="3" /></div></td>
  <td width="180" height="22" style="padding:5">
<a href="softinfo.php?id=<?php echo $infouwz["id"];?>" class="a1">
  <?php  
if($i==1)
{
echo "<font color=red>";
}
echo unhtml(msubstr($infouwz["softname"],0,16));
if(strlen($infouwz["softname"])>16)
{
echo " .";
}
  echo "<font color=red>[".substr(str_replace("-","/",$infouwz[addtime]),0,10)."]</font>";  
if($i==1)
{
echo "</font>";

  ?>
  </a> 
</td>
  </tr>
  <tr>
  <td height="1" colspan="2" background="images/line_1.gif"></td>
  </tr>
  <?php
$i++;
}while($infouwz=mysql_fetch_array($sqluwz));
}
?>
  </table>
</td>
</tr>
  </table>
</td>
  </tr>
  </table>


网页提示错误

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource ……

------解决方案--------------------
你要明白 do....while结构。。。这个不管条件是否成立,都会循环一次。

建议改成:

while($infouwz=mysql_fetch_array($sqluwz))
{
//do something here....
}
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource …… 报这样的错误,你就得在mysql_query($sql