新手半夜求解:Unknowncolumn'qq'in'fieldlist'如何解决
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了新手半夜求解:Unknowncolumn'qq'in'fieldlist'如何解决,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3077字,纯文字阅读大概需要5分钟。
内容图文
新手半夜求解:Unknown column 'qq' in 'field list'怎么解决这个是我自己练习的时候遇到的问题,新手,别笑话...
这个是建表的代码:
$con=@mysql_connect('localhost','root','123');
if($con)
{
mysql_select_db("employee",$con);
$sql="CREATE TABLE personal_data
(
id int(5) not null auto_increment primary key,
name char(10) not null,
qq char(16) not null,
tel char(14) not null,
email char(20) not null,
social_security char(22) not null,
postcode char(15) not null,
home_add char(26) not null,
home_tel char(14) not null,
residence_registration char(10) not null,
nation_place char(14) not null
)";
$do=mysql_query($sql,$con);
if($do)
{
echo "成功在employee数据库中创建用户表!";
}
else echo "建表有错误...";
}
else
{
echo "连接错误";
}
?>
因为分不是很清楚int 和 char 的区别,所以都是用 char 。
这个是deal的代码:
echo " ";
if($_POST)
{
$name=$_POST["name"];
$qq=$_POST["qq"];
$tel=$_POST["tel"];
$email=$_POST["email"];
$social_security=$_POST["social_security"];
$postcode=$_POST["postcode"];
$home_add=$_POST["home_add"];
$home_tel=$_POST["home_tel"];
$residence_registration=$_POST["residence_registration"];
$nation_place=$_POST["nation_place"];
$con=mysql_connect("localhost","root","123");
mysql_select_db("employee");
mysql_query("SET NAMES GB2312");
$sql="SELECT COUNT(*) FROM personal_data WHERE name='$name'";
$result=mysql_query($sql);
$num=mysql_fetch_row($result);
if($num[0]>0)
{
echo "存在同名用户,重新输入用户名!";
}
else
{
$sql="INSERT INTO staff_information(name,qq,tel,email,social_security,postcode,home_add,home_tel,residence_registration,nation_place) VALUES ('".$name."','".$qq."','".$tel."','".$email."','".$social_security."','".$postcode."','".$home_add."','".$home_tel."','".$residence_registration."','".$nation_place."')";
$re=mysql_query($sql)or die(mysql_error());
if($re) echo "成功插入记录!";
else echo "插入记录失败!";
echo "
";
}
}
else
{
echo "没有提交内容!
";
}
echo "
点这里返回";
?>
大学里的新手,研究了几个小时了,百度谷歌了好久都解决不了,希望有高手可以帮我,万分感谢。
------解决方案--------------------
1.int 是整数类型 char 是字符类型 现在一般使用varchar
int:从 -2^31 (-2,147,483,648) 到 2^31 - 1 (2,147,483,647) 的整型数据(所有数字)。存储大小为 4 个字节
char 和varchar:CHAR列的长度固定为创建表时声明的长度。长度可以为从0到255的任何值。当保存CHAR值时,在它们的右边填充空格以达到指定的长度。当检索到CHAR值时,尾部的空格被删除掉。在存储或检索过程中不进行大小写转换。
VARCHAR列中的值为可变长字符串。长度可以指定为0到65,535之间的值。(VARCHAR的最大有效长度由最大行大小和使用的字符集确定。整体最大长度是65,532字节)。
2.qq 这个字段在数据库里不存在
------解决方案--------------------
- SQL code
CREATE TABLE personal_data ( id int(5) not null auto_increment primary key, name char(10) not null, qq char(16) not null, tel char(14) not null, email char(20) not null, social_security char(22) not null, postcode char(15) not null, home_add char(26) not null, home_tel char(14) not null, residence_registration char(10) not null, nation_place char(14) not null )
------解决方案--------------------
内容总结
以上是互联网集市为您收集整理的新手半夜求解:Unknowncolumn'qq'in'fieldlist'如何解决全部内容,希望文章能够帮你解决新手半夜求解:Unknowncolumn'qq'in'fieldlist'如何解决所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。