incorrect table definition; there can be only one auto column and it must be defined as a key

来源:百度知道 编辑:UC知道 时间:2024/05/16 20:40:39
什么意思?

只能有一个自动增长列,并且必须定义一个主键

不正确表格定义;只有一个自动专栏,并且必须定义它为关键

不正确表格定义;只可以有一个自动专栏,并且必须定义它作为关键

不正确表定义;只能有一个自动栏,它必须被定义为关键

2012-2013新版视频中的id在php的sql语句中老师插入id用了NULL,但由于我把id设置为自增字段,它就被默认成了主键,而主键不能为空,然后我试了试插入id时,用两个单引号'',就解决了问题。
<?php
include("conn.php");//引入连接数据库
//如何判断表单是否已经提交
//empty()函数用来判断是否为空
if (!empty($_POST['sub'])){
$title=$_POST['title'];
$con=$_POST['con'];
$sql="insert into `news` (`id`,`title`,`dates`,`contents`) values ('','$title',now(),'$con')";
mysql_query($sql);
echo "插入成功";
}
?>
<form action="add.php" method="post">
标题<input type="text" name="title"><br>
内容<textarea rows="5" cols="50" name="con"></textarea><br>
<inp