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

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\wamp\www\messageboard\list.php on line 22

错误解析:说明参数传递错误,数据库连接不成功。

原因:mysql_select_db("messageboard",$conn);//使用错误,是选择数据库名,修改数据库名后忘了在文件中修改

 

程序如下

<?php
    $conn=@mysql_connect("localhost","root","")or die("数据库连接错误");//连接数据库
    mysql_select_db("messageboard",$conn);//选择数据库中的表(选择数据库名
    mysql_query("set names 'GBK'");//使用GBK中文编码
?>

<style type="text/css">

#bottom{  background-color:#CFC;  }

#top{   background-color:#DDFFFF; }

</style>

<table width="500px" height="aoto">

<?  

  $sql="select* from message";  

  $query=mysql_query($sql);  

  while($row=mysql_fetch_array($query)){

?>

   <tr>

      <td id="top">标题:<?=$row[title]?>时间:<?=$row[lastdata]?></td>  

    </tr>  

    <tr>   

        <td id="bottom">内容:<?=$row[content]?></td>

     </tr>

  <?   }   ?>

</table>

 

posted @ 2012-09-27 15:38  EVERYDAY2012  阅读(1121)  评论(0)    收藏  举报