乐山市交委app:关于php编程

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/05 04:19:02
我在用php做留言板的回复页面的时候,总是提示
“数据库查询失败You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1”

我的数据库名字是“liuyan”,里面有个数据表,页叫“liuyan”而“huifu”是数据表“liuyan”里面的一个字段。
我实在找不到是那里错了,谁能帮我看看啊?
下面是我的代码:

<?php include("adminyanzheng.php")?>
<?php include("conn.php")?>
<?php
if($_POST["Submit"]=="提交")
{
?>
<?php
$sql="update liuyan set huifu='".$_POST["huifu"]."' where xuhao=".$_POST["id"];
$result=mysql_query($sql,$conn) or die("修改数据库失败".mysql_error());
mysql_close($conn);
if($result)
{ header("location:show.php");
exit;
}
else
{ echo "修改数据库失败";}
?>
<?php
}

?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>管理员回复</title>
</head>
<body>
<?php
$sql="select * from liuyan where xuhao=".$_GET["id"];
$result=mysql_query($sql,$conn) or die("数据库查询失败".mysql_error());
$row=mysql_fetch_array($result);
mysql_close($conn);
?>
<form id="form1" name="form1" method="post" action="">
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
<tr>
<td width="75" height="42">用户名</td>
<td width="525">
<input name="name" type="text" value="<?php echo $row["name"] ?>" readonly>
<!--<label name="user" type="text"><?php echo $row["name"] ?></label> -->
<input type="hidden" name="id" value="<?php echo $_GET["id"] ?>"> </td>
</tr>
<tr>
<td height="39">回复内容</td>
<td>
<textarea name="huifu" cols="60" rows="8"></textarea>
</td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="Submit" value="提交" />
<input type="reset" name="Submit2" value="重置" />
</label></td>
</tr>
</table>
</form>
</body>
</html>

谢谢各位了!!!