新手半夜求解:Unknown column 'qq' in 'field list'如何解决

WBOY
풀어 주다: 2016-06-13 13:35:57
원래의
1557명이 탐색했습니다.

新手半夜求解: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
)
<br><font color="#e78608">------解决方案--------------------</font> <div class="clear">
                 
              
              
        
            </div>
로그인 후 복사
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!