代码如下:<?php
/*
 * Created on 2012-1-1
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 $conn = mysql_connect("localhost","root","") or die ("连接出错");
 mysql_select_db("dongxinb",$conn); $sql="SELECT * FROM 'word'";
 $query=mysql_query($sql,$conn);
 $row=mysql_fetch_array($query);
 echo $row[name];
?>其中name为dongxinb数据库word表的字段。
错误信息:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\wamp\www\word\1.php on line 13其中INSERT能正常插入。

解决方案 »

  1.   

    SQL 错了修改成
    $sql="SELECT * FROM word";
      

  2.   

    <?
    /*
     * Created on 2012-1-1
     *
     * To change the template for this generated file go to
     * Window - Preferences - PHPeclipse - PHP - Code Templates
     */
    include("conn.php");?><table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
    <?
     $sql="select * from word";
      $query=mysql_query($sql);
      while($row=mysql_fetch_array($query)){
    ?>
      <tr bgcolor="#eff3ff">
      <td>姓名:<? echo $row[name]?></td>
      </tr>
      <tr bgColor="#ffffff">
      <td>Message:<?=$row[words]?></td>
      <td>更新时间:<?=$row[date]?></td>
      </tr><?
      }
    ?></table>
    那么这个哪里错了?
    没有数据库的内容输出……很郁闷。INSERT也能用?
    其中name date words都是字段。和刚才那段话同个数据库,上面删掉‘’之后可以输出了。
    但是这个还是不能用……
      

  3.   

      <td>姓名:<? echo $row[name]?></td>
    这句话改成    <td>姓名:<?=$row[name]?></td>
      

  4.   

    php大神,能否看看?感激不尽……
      

  5.   

    <? echo $row[name]?><?=$row[words]?>change to<?php echo $row['name'];?><?php echo $row['words'];?>
    ...
      

  6.   


    no 大神,在看资料 偶尔回来刷新csdn  才看到还有问题.
      

  7.   

      <td>姓名:<?php echo $row['name']; ?></td>
      </tr>
      <tr bgColor="#ffffff">
      <td>Message:<?php echo $row['words']; ?></td>
      <td>更新时间:<?php echo $row['date']; ?></td>
    改成这样吗?可是,问题照旧,没有输出。
      

  8.   

    while($row=mysql_fetch_array($query)){
    print_r($row);
    ?>输出结果看看是什么.
      

  9.   

    没有输出东西吗? 结果页面没有 array() 什么的之类?不可能吧?
      

  10.   

    include("conn.php");
    conn.php 有没问题?
      

  11.   

    应该没有问题。
    用INSERT语句都可以。
      

  12.   


    <?php
    /*
     * Created on 2012-1-1 To change the template for this generated file go to
     * Window - Preferences - PHPeclipse - PHP - Code Templates
     */
    include ("conn.php");
    ?><table width=500 border="0" align="center" cellpadding="5"
    cellspacing="1" bgcolor="#add3ef">
    <?php
    $sql = "select * from word";
    $query = mysql_query ( $sql );
    while ( $row = mysql_fetch_array ( $query ) ) {
    echo <<<html
      <tr bgcolor="#eff3ff">
      <td>姓名:{$row['name']}</td>
      </tr>
      <tr bgColor="#ffffff">
      <td>Message:{$row['words']}</td>
      <td>更新时间:{$row['date']}</td>
      </tr>
    html;
    }
    ?></table>
    试看看是否正常,我已经测试过正常了。代码看起来不像有问题.