[原创]简易聊天室问题 |
请站长和高手们帮我看一下啊`~`
1.同一个ID不能连续发送2句话,第二句话进不了数据库.2.ID为空时,即2.ID为"路人"时,为什么不能发送语句?
以下是代码(共3个文件):
第一个<chat.php>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<frameset rows="70%,30%" framespacing="0" frameborder="NO" border="1">
<frame src="/list.php" >
<frame src="/type.php" >
</frameset><noframes></noframes>
</html>
第2个 <list.php>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="refresh" content="3; url=list.php">
<title>无标题文档</title>
</head>
<body>
<?
$db=mysql_connect("localhost","root","");
mysql_select_db("chat",$db);
$dbq=mysql_query("select id,words from mychatdb order by datetime desc limit 0,20");
$dbt=mysql_num_rows($dbq);
echo "<table cellpadding=0 cellspacing=0 border=0 width=90% >";
for ($t=$dbt-1;$t>=0;$t--)
{
mysql_data_seek($dbq,$t);
$dbrow=mysql_fetch_row($dbq);
$id=$dbrow[0];
$words=$dbrow[1];
echo "<tr> <td width=10%>$id</td>";
echo "<td width=5% align=center>: </td>";
echo "<td width=85%>$words</td></tr>";
}
echo "</table>";
mysql_close($db);
?>
</body>
</html>
第3个 <type.php>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<?
$db=mysql_connect("localhost","root","");
mysql_select_db("chat",$db);
if ($chatid=="") $chatid="路人";
if (isset($words))
$dbq=mysql_query("insert into mychatdb values ('$chatid','$words',now())");
echo "<table width=99% cellpadding=0 cellspacing=0 border=9>\n";
echo "<tr>";
echo "<td align=left><font size=2><b>";
echo "<form method=get action=type.php>\n";
echo "$chatid: <input type=text size=50 maxlength=160 name=words value=\"\">";
echo " <input type=hidden name=chatid value=\"".$chatid."\">";
echo " <input type=submit name=sendout value=\"送出\"> ";
echo "</form>";
echo "</font></td>";
echo "<td align=left><font size=2><b>";
echo "<form method=get action=type.php>\n";
echo "<input type=text size=12 maxlength=160 name=chatid value=\"\">";
echo " <input type=submit name=renamebutton value=\"重命名称\"> ";
echo "</form>";
echo "</font></td>";
echo "</tr>";
echo "</table>";
mysql_close($db);
?>
</body>
</html>
看起来比较麻烦 ,,各位耐心点啊~~~小弟拜谢~
|
|
|