<?php
mysql_connect('localhost','root','');
    mysql_query("set names gb2312");
mysql_select_db("guangbo");$cm="select title,author,date from comments";
$rs=mysql_query($cm);
/*Dim conn,rs
Dim connstr
Dim sqlCmd
'创建数据库连接对象并打开
$conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0;data source=" & server.mappath("GuestBook.mdb")
conn.open connstr
'用于从数据库中获取数据的sql语句
sqlCmd="select title,author,date,content from data order by date desc"
'创建数据集对'
从数据库中获取数据
rs.open sqlCmd,conn,1,1象*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
<!--
//将用户输入异步提交到服务器
function ajaxSubmit(){
 //获取用户输入
 var title=document.forms[0].title.value;
 var author=document.forms[0].author.value;
 var content=document.forms[0].date.value;
 //创建XMLHttpRequest对象
 var xmlhttp;
 try{
  xmlhttp=new XMLHttpRequest();
 }catch(e){
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
 //创建请求结果处理程序
 xmlhttp.onreadystatechange=function(){
  if (4==xmlhttp.readyState){
   if (200==xmlhttp.status){
    var date=xmlhttp.responseText;
    addToList(date);
   }else{
    alert("error");
   }
  }
 }
 //打开连接,true表示异步提交
 xmlhttp.open("post", "gbzinsert.php", true);
 //当方法为post时需要如下设置http头
 xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
 //发送数据
 xmlhttp.send("title="+escape(title));
}
//将用户输入显示到页面
function addToList(date){
 //获取留言列表div容器
 var msg=document.getElementByIdx("msgList");
 //创建dl标记及其子标记
 var dl=document.createElement("dl");
 var dt=document.createElement("dt");
 var dd=document.createElement("dd");
 var dd2=document.createElement("dd");
 //将结点插入到相应的位置
 msg.insertBefore(dl,msg.firstChild);
 dl.appendChild(dt);
 dl.appendChild(dd);
 dl.appendChild(dd2);
 //填充留言内容
 dt.innerHTML="标题:"+document.forms[0].title.value;
 dd.innerHTML="作者:"+document.forms[0].author.value;
 dd2.innerHTML=document.forms[0].date.value;
 //清空用户输入框
 document.forms[0].title.value="";
 document.forms[0].author.value="";
 document.forms[0].date.value="";
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<div id="msgList"><?php 
while($row=mysql_fetch_array($rs)){
echo $row['title'];
echo "<br>";
}
?>
</div>
<div id="postBox">
 <form name="theForm" method="post">
  <dl>
   <dt>发表您的留言</dt>
   <dd>标题:<input type="text" maxlength="150" size="45" name="title"/></dd>
   <dd>作者:<input type="text" maxlength="50" size="45" name="author"/></dd>
   <dd>内容:<textarea rows="10" cols="45" name="date"></textarea></dd>
   <dd class="button">
    <input type="button" onClick="ajaxSubmit()" value="提交"/>
    <input type="reset" value="重填"/>
   </dd>
  </dl>
 </form>
</div>
</body>
</html>--------------------
提交之后数据库里插入成功了,但是DIVMSGLIST里没有内容自动更新~~~哪里出问题了?