<?php
include("conn.php");
?>
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?
 $sql="select * from message";
 $query=mysql_query($sql);
  while($row=mysql_fetch_array($query)){?>
<tr bgcolor="#eff3ff">
  <td>  标题: <?=$row[title]?>   用户:<?=$row[user]?></td>
  </tr>
  <tr bgColor="#ffffff">
  <td>内容:<?=$row[content]?></td>
  </tr>
  <?
  }
  ?>
</table>
前面已经建留言板好数据库,并且添加了数据为什么不能调用出来title 和content 还有user的里面的内容?
高手给看看啊 
弄了一下午还是不行。来人啊。

解决方案 »

  1.   

    楼主得贴出来报什么错
    先试试$row['title']
      

  2.   

    还是不行 加了引号$row['title']
      

  3.   

    <?=$row[title]?> 请使和标准写法<?php echo $row['title'];?>
      

  4.   


    <?php
    include("conn.php");
    ?>
    <table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
    <?
     $sql="select * from message";
     $query=mysql_query($sql);
      while($row=mysql_fetch_array($query)){
    //试一下,先确认你已成功从数据库里读取数据。
              var_dump($row);  }
      ?>
    </table>
      

  5.   

    这是链接数据库的文件
    <?php
    $conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
    mysql_select_db("bbs", $conn);
    mysql_query("set names 'GBK'"); //使用GBK中文编码;
    ?>
      

  6.   


    这是更新留言内容的文件
    <?php
    include("conn.php");
     if($_POST['submit']){
      $sql="insert into message (id,user,title,content,lastdate) values('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
     mysql_query($sql);
     echo "发表成功";
     }?>  <form action="add.php" method="post">
      用户:<input type="text" size="10" name="user" /></br>
      标题:<input type="text" name="title"  /></br>
      内容:<textarea name="content"></textarea></br>  <input type="submit" name="submit" value="发布留言"/>
      </form>
      

  7.   

    我的也是这个问题
    根本form里的数据就没写入到数据库中
      

  8.   

    <?=$row[title]?>  这是短标签写法,规则写法为:<?php echo $row['title'];?>   你也可以在php环境中修改一下,支持短标签也可以的。
      

  9.   

    可以查看数据库日志么???
    tail -f log.log
      

  10.   

    先print_r($row)看有没有结果再说
      

  11.   

    $sql="insert into message (id,user,title,content,lastdate) values('','$_POST[user]','$_POST[title]','$_POST[content]',now())";php 有 now() 这个函数?
      

  12.   

    <? php 
       $sql="select * from message";
     $query=mysql_query($sql);
      while(……
      

  13.   


    首先 你的写法相当的不规范
    注意此处<?=$row[content]?>
    改成<?php echo $row[content]?>