当前位置:编程学习 > php >>

PHP与HTML混编就出错

<?php

 include("conn.php");

 include("head.php");

?>

<table width=500 border="0" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?
 $SQL="SELECT * FROM `message` order by id desc";
  $query=mysql_query($SQL);
  while($row=mysql_fetch_array($query)){
?>
  <tr bgcolor="#eff3ff">
  <td>标题:<?=$row[title]?> 用户:<?=$row[user]?></td>
  </tr>
  <tr bgColor="#ffffff">
  <td>内容:<?
 echo htmtocode($row[content]);
   ?></td>
  </tr>
  <?
  }
?>
</table>

 

 

------------------------------------------------------------------------------------------------------

代码如上  注释掉HTML代码 就能显示数据 不注释就不显示 而且不报错 只能正常显示HTML代码 没有显示数据

追问:果然好用了 是配置文件的事么 怎么设置 太感谢了
答案:不知道你注释掉html之后代码是什么样子的。猜测可能你的short_tag没有打开,你换成如下代码试试:
<?php
include("conn.php");
include("head.php");
?>

<table width=500 border="0" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?php
$SQL="SELECT * FROM `message` order by id desc";
$query=mysql_query($SQL);
while($row=mysql_fetch_array($query)){
?>
  <tr bgcolor="#eff3ff">
  <td>标题:<?php=$row[title]?> 用户:<?php=$row[user]?></td>
  </tr>
  <tr bgColor="#ffffff">
  <td>内容:<?php echo htmtocode($row[content]); ?></td>
  </tr>
<?php
}
?>
</table>

你文件的扩展名是.php吗?

上一个:如何安装SQL2005 IIS php
下一个:php查询后页面无法返回

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,