php 求助

<?php
include './top.php';
include '../conn.php';
mysql_select_db($my_db,$con);
if(!$_GET['action']=='1'){
//没提交表单
echo '<title>后台 - 发表博文</title><body><form action="?action=1" method="post">
分类名称:<input type="text" name="fenlei" /><br />
博文内容:<textarea name="blog" rols="40" rows="30"></textarea><br />
<input type="submit" value="发表" />
</form></body>';
}else{
//提交了表单
$result=mysql_query("SELECT * FROM blog");
//选取blog表
$id=mysql_num_rows($result);
//该表一共多少行
$id=$id+1;
$user='博主';
$fenlei=$_POST['fenlei'];
$content=$_POST['blog'];
$date=time();
$sql="INSERT INTO blog(id,user,fenlei,content,date) VALUES($id,$user,$fenlei,$content,$date)";
if(mysql_query($sql))
echo "发表成功!";
else
echo "发表失败!<br />原因:".mysql_error();
mysql_close($con);
}
?>



提交后输出:
发表失败!
原因: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 '��主,分类名,这是测试内容,1391938171)' at line 1
回复列表(7|隐藏机器人聊天)
添加新回复
回复需要登录