[code={php}]
<?php
include("conn.php");
?>
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?
 $sql = "SELECT * FROM message ORDER BY id ASC ";
$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>
[/code]
我的conn.php文件没问题
可是为什么不显示输出结果

解决方案 »

  1.   

    把错误模式打开,然后EALL就有错误出来了
      

  2.   

    <table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
    <?
     $sql = "SELECT * FROM message ORDER BY id ASC ";
     echo $sql;
    $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>
    这是打开网页后的源文件
      

  3.   

    你的服务器都没有解析php语句,都是原文输出到客户端了,安装问题。
      

  4.   

    写个文件
    <?php
    phpinfo();
    ?>
    看看能不能运行,首先要服务器能解析php,然后才会有short_open_tag的设置,如果你服务器都没有设置好处理php所有php.ini设置没意义
      

  5.   

    你先别用while,你先简单的在表中取一个数据,看能不能显示
      

  6.   

    <?=$row[title]?> => <? echo $row[title]?> 没有echo 怎么显示呀
      

  7.   

    <?=$var?>是<?php echo $var; ?>的简写,但需要short_open_tag支持
      

  8.   

    9楼说的问题,我的wamp程序没问题
    10楼的,我试了还是显示不了
      

  9.   

    我的short_open_tag
    已经激活了
    但是就是读取不了短标记
      

  10.   

    那就
    <?php echo $row["xxx"];?>
      

  11.   

    估计就是#9楼所说的短标签的问题.你把所有的<?开始标签用正统的<?php代替
      

  12.   

    我的短标记在php.ini里面把short_open_tag=on了
    但是我用phpinfo()函数显示时
    short_open_tag=off,
    现在我该怎么设置才能把短标记激活
      

  13.   

    你phpinfo里面的Loaded Configuration File是什么值,是不是你修改的php.ini文件
      

  14.   

    找不到你说的Loaded Configuration File
      

  15.   

    通常应该在phpinfo最上第一块信息的中间偏上部分
      

  16.   

    谢谢21楼的大哥了。按照你说的方法短标记激活了
    但是代码又出现错误了
    [code={php}]
    <?php
    include("conn.php");
    ?>
    <table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
    <?
     $sql = "SELECT * FROM message ORDER BY id ASC ";
    $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>
    [/code] 
    运行后报的错误
    Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\BBS\list.php on line 7Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\BBS\list.php on line 7Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\BBS\list.php on line 8
      

  17.   

    检查你的conn.php,根本没有连接上数据库
      

  18.   

    对了,short_open_tag已经快要入土了,还是建议尽量不要使用的
      

  19.   

    我的conn.php文件
    在另外一个页面里面就正常的可以引用
    我是刚学的,看的视频上面用这个
    我就用这个
      

  20.   

    你的这个文件和conn.php放在一起的吗?
    如果是,conn.php文件内容?
      

  21.   

    不是
    conn.php文件单独的页面
    <?php
    function db_connect()
    {
    $db = @ new mysqli("127.0.0.1","root","","bbs");
    if (mysqli_connect_errno())
    {
    echo "数据库连接失败";
    echo mysqli_connect_error();
    exit;
    }
    return $db;
    }
    ?>
    我现在把这个页面改成
    <?php
    include("conn.php");
    ?>
    <table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
    <?
    $db  = db_connect();
     $sql = "SELECT * FROM message ORDER BY id ASC ";
    $rs =$db->query($sql);
    while($row=mysql_fetch_array($rs))
    {
    ?>
      <tr bgcolor="#eff3ff">
      <td>标题:<?=$row[title]?> 用户:<?=$row[user]?></td>
      </tr>
      <tr bgColor="#ffffff">
      <td>内容:<?=$row[content]?></td>
      </tr>
      <?
      }
    ?>
    </table>
    报的错误是
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\BBS\list.php on line 9
      

  22.   

    谢谢“Siramizu”大侠了
    我的问题解决了
      

  23.   

    连接用的是mysqli不是mysql
    while($row=mysql_fetch_array($rs)) 这个地方也要用mysqli的mysqli_fetch_array