为什么我无法在我的数据库中插入?这是我的代码提交表格时出错
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$bdate = $_POST['bdate'];
$id = $_POST['id'];
if (!empty($name) && !empty($email)){
mysql_query("insert into customer(id,name,email,bdate) values($id,'$name','$email','$bdate')");
}
else {
echo "Please fill <strong>name</strong> and <strong>e-mail</strong> fields!";
}
?>
我的形式是
<form method="post" action="new_customer.php">
ID: <input type="text" name="id" size="5" value="<?php echo $new_id; ?>" disabled="disabled" /><br />
Name: <input type="text" name="name" size="50" /><br />
E-mail: <input type="text" name="email" size="30" /><br />
Birth Date: <input type="text" name="bdate" size="10" /><br /><br />
<input type="submit" value="Save" />
</form>
的变量$ NEW_ID充满了该查询
SELECT (Max(id) + 1) as new_id FROM customer
但是,当我提交表单,我得到的错误是:
Notice: Undefined index: id in F:\UniServer\www\admin\customer.php on line 6
然后mysql错误
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
我认为第一个错误会导致secund,对吗?
什么是id如果它是你的自动增量id然后删除它并尝试 – 2011-12-16 13:03:28