php对数据库的操作有关问题!很急

php对数据库的操作问题!很急!
对数据库的添加为什么老是显示添加失败?????
<?php
error_reporting(E_ALL & ~E_NOTICE);
    $conn=mysql_connect("localhost","root","root") or die("数据库服务器连接错误".mysql_error());
    mysql_select_db("bill",$conn) or die("数据库访问错误".mysql_error());
    mysql_query("set names gb2312");
$article=$_POST['txt_article'];
$type=$_POST['txt_type'];
$money=$_POST['txt_money'];
$remark=$_POST['txt_remark'];
$date=date("Y-m-d");
$sql=mysql_query("insert into tb_pay(article,type,money,remark,date)values('$article','$type','$money','$remark','$date')");
if($sql){
echo "<script>alert('数据添加成功!');window.location.href='zhangdan.php';</script>";
}else{
echo "<script>alert('数据添加失败!');history.back();window.location.href='doAdd.php';</script>";
}

mysql_free_result($sql);
mysql_close($conn);
?>








对数据库的修改为什么老是显示添加失败?????
<?php
error_reporting(E_ALL & ~E_NOTICE);
$conn=mysql_connect("localhost","root","root") or die("数据库服务器连接错误".mysql_error());
mysql_select_db("bill",$conn) or die("数据库访问错误".mysql_error());
mysql_query("set names gb2312");
$date=date("Y-m-d ");
$article=$_POST[article];
$type=$_POST[type];
$money=$_POST[money];
$remark=$_POST[remark];
$id=$_POST[id];
$sql=mysql_query("update tb_pay set date='$date',article='$article',type='$type',money='$money',remark='$remark' where id=$id");
if($sql){
echo "<script>alert('编辑数据成功!');history.back();window.location.href='zhangdan.php?id=$id';</script>";
}else{
echo "<script>alert('编辑数据失败!');history.back();window.location.href='zhangdan.php?id=$id';</script>";
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
------解决方案--------------------
$sql=mysql_query("insert into tb_pay(article,type,money,remark,date)values('$article','$type','$money','$remark','$date')") or die(mysql_error());