我要插入的记录已成功插入,但后面有几条空白的数据,只有时间。我的目的是只有我要插入的就行。
如图
下面是我的代码
<?
$action=@$_GET["action"];
if($action=="save"){
$name=check_sub($_POST["name"]);
$sex=check_sub($_POST["sex"]);
$address=check_sub($_POST["address"]);
$tel=check_sub($_POST["tel"]);
$cellphone=check_sub($_POST["cellphone"]);
$email=check_sub($_POST["email"]);
$qq=check_sub($_POST["qq"]);
$content=check_sub($_POST["content"]);
$addtime=date('Y-m-d H:i:s');

if($name=="")
echo "<script>location.href='?';</script>";

$sql_add="insert into feedbook (names,sex,address,tel,cellphone,email,qq,content,addtime)";
$sql_add=$sql_add." values ('$name','$sex','$address','$tel','$cellphone','$email','$qq','$content','$addtime')";
echo $sql_add;
//die;
mysql_query($sql_add);

if(mysql_affected_rows()>0)
echo "<script>alert('Information added successfully!');location.href='?';</script>";
else
{
echo "error!".$sql_add;
die();
}
}
?>打印出来的sql语句是
insert into feedbook (names,sex,address,tel,cellphone,email,qq,content,addtime) values ('stewen','男','tian he city','020-86187459','18602066783','[email protected]','378922121','contentntn','2013-07-16 16:07:52')直接在mysql里执行也只插入一行数据没有产生多余的。