菜鸟问题。。。。求助
kel1984
![]()
|
1#
kel1984 发表于2007-05-16
菜鸟问题。。。。求助
请问这段代码为什么写不进去数据库呢???
<?php //<!--update.php:修改留言信息---------------> //修改完毕后,返回留言列表页面 if(isset($_POST["recordid"])) { $recordid=$_POST["recordid"]; } elseif(!isset($_GET["recordid"])) { echo "<script language='javascript'>"; echo " location='booklist.php?keyword=&search=1'"; echo "</script>"; } if(isset($recordid)) { /*echo "<script language='javascript'>alert('dfgg');</script>";*/ require_once("sys_conf.inc"); //初始化页面表单中的值 //连接数据库 $link_id=mysql_connect($DBHOST,$DBUSER,$DBPWD); mysql_select_db($DBNAME); //选择数据库auction $str="select name,homepage,location,email,message,content from guestbook where rid=".$recordid; echo $str; $result=mysql_query($str,$link_id); list($name2,$homepage2,$location2,$email2,$message2,$content2)=mysql_fetch_row($result); //echo $name2; //判断姓名和留言信息是否为空 $errorm=""; if (!isset($message) or $message=="" or !isset($name) or $name=="") { $errorm="<font color=red>出错了!!!</font>姓名和留言内容必填"; } else { //获取并处理用户提交信息 $space = " "; $time = date("Y年m月d日H小时i分"); $ip=$REMOTE_ADDR; $message=StripSlashes($message); //给字符串中按照需要加上"\"和去掉"\",对于某些数据库,必须在要查询的字符加上和去掉"\"之后才能够查询. $message=htmlspecialchars($message); //将HTML特殊字符换成它们的名字,例如"<"变成"<". $message=nl2br($message); //在HTML中的每一个回车前面加上"<BR>". $guestcontent = "<tr><td><font color=#AB00E1>留言内容:</font><br><!--content>$message<!--endcontent> "; $guestcontent=$guestcontent."<br><font color=#6633FF>留言人大名: </font><!--name>$name<!--endname> "; if ($email !="") {$guestcontent=$guestcontent."<br><font color=#9900CC>电子信箱:</font><a href=\"mailto:$email\"><!--email>$email<!--endemail></a>"."$space";} if ($homepage !="http://") {$guestcontent=$guestcontent."<font color=#9900CC>主页:</font>$hompage<a href=\"$homepage\"><!--homepage>$homepage<!--endhomepage></a>";} if ($location !="") $guestcontent=$guestcontent."<br><font color=#0000FF>时间:$time 来自:$location $ip</font>"; $guestcontent=ereg_replace(chr(10),"",$guestcontent); $guestcontent=$guestcontent."<hr size=1></td></tr>\n"; //修改数据库 $str="update guestbook set"; $str=$str."time='$time',ip='$ip',name='name',homepage='homepage',"; $str=$str."location='location',email='email',content='guestcontent',"; $str=$str."where rid=$recordid"; echo $str; $result=mysql_query($str,$link_id); //执行查询 mysql_close($link_id); echo "<script language='javascript'>"; echo " location='booklist.php?keyword=&search=1'"; echo "</script>"; } } ?> <html> <style type=text/css> Td {FONT-SIZE: 10pt;} TEXTAREA { FONT-FAMILY: "宋体"; FONT-SIZE: 10pt; } </style> <head> <title>修改留言</title> </head> <body bgcolor=#FFFFFD> <?php include "head1.html"?> <div align="center"> <table width="68%" border="1" cellpadding="3" cellspacing="0" bordercolor="#E3E3E3"> <form method="POST" action="update.php"> <? //如果输入的用户名或留言信息为空,则报错 if ($errorm) { echo "<tr>"; echo "<td colspan=3 height=32> "; echo "$errorm"; echo "</td>"; echo "</tr>"; } ?> <tr> <td width="22%" bgcolor="#F0F0F0"><font color="#000000">姓名<font color="#FF0033">(必填)</font></font></td> <td colspan="2" width="78%" bgcolor="#F0F0F0"><font color="#00FF00"> <input type="text" name="name" value="<?php echo "$name2"?>" size="40"> </font></td> </tr> <tr> <td width="22%" height="29">主页:</td> <td colspan="2" height="29" width="78%"> <input type="text" name="homepage" value="<?php echo "$homepage2"?>"size="40"> </td> </tr> <tr> <td width="22%" height="27" bgcolor="#F0F0F0">来自:</td> <td colspan="2" height="27" width="78%" bgcolor="#F0F0F0"> <input type="text" name="location" value="<?php echo "$location2"?>" size="40"> </td> </tr> <tr> <td width="22%" height="20">Email:</td> <td colspan="2" height="20" width="78%"><font color="#00FF00"> <input type="text" name="email" value="<?php echo "$email2"?>" size="40"> </font></td> </tr> <tr> <td colspan="3" valign="middle" align="left"> <div align="center"><font color="#000000">请留言</font><font color="#FF0033">(必填)</font><font color="#00FF00"><br> <textarea rows="6" name="message" cols="55" wrap="VIRTUAL"><?php echo "$message2"?></textarea> </font></div> </td> </tr> <tr bgcolor="#F0F0F0"> <td colspan="3" height="24"> <div align="center"><font color="#00FF00"> <input type="submit" value="提 交" name="B1"> <input type="reset" value="重 写" name="B2"> </font></div> </td> </tr> </form> </table> </body> </html> |