Home Backend Development PHP Tutorial 新手半夜求解:Unknown column 'qq' in 'field list'如何解决

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

Jun 13, 2016 am 10:11 AM
char home NOT null quot

新手半夜求解:Unknown column 'qq' in 'field list'怎么解决
这个是我自己练习的时候遇到的问题,新手,别笑话...

这个是建表的代码:
[email protected]_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>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between null and NULL in c language What is the difference between null and NULL in c language Sep 22, 2023 am 11:48 AM

The difference between null and NULL in C language is: null is a macro definition in C language, usually used to represent a null pointer, which can be used to initialize pointer variables, or to determine whether the pointer is null in a conditional statement; NULL is a macro definition in C language A predefined constant in , usually used to represent a null value, used to represent a null pointer, null pointer array or null structure pointer.

What do undefined and null mean? What do undefined and null mean? Nov 20, 2023 pm 02:39 PM

In JavaScript, both undefined and null represent the concept of "nothing": 1. undefined represents an uninitialized variable or a non-existent property. When a variable is declared but no value is assigned to it, the value of the variable is undefined , when accessing properties that do not exist in the object, the returned value is also undefined; 2. null represents an empty object reference. In some cases, the object reference can be set to null to release the memory it occupies.

What is the difference between null and undefined What is the difference between null and undefined Nov 08, 2023 pm 04:43 PM

The difference between null and undefined is: 1. Semantic meaning; 2. Usage scenarios; 3. Comparison with other values; 4. Relationship with global variables; 5. Relationship with function parameters; 6. Nullability check; 7. Performance considerations; 8. Performance in JSON serialization; 9. Relationship with types. Detailed introduction: 1. Semantic meaning, null usually means knowing that this variable will not have any valid object value, while undefined usually means that the variable has not been assigned a value, or the object does not have this attribute; 2. Usage scenarios, etc.

When to use null and undefined When to use null and undefined Nov 13, 2023 pm 02:11 PM

Both null and undefined indicate a lack of value or an undefined state. Depending on the usage scenario, there are some guiding principles for choosing to use null or undefined: 1. When you need to clearly indicate that a variable is empty or invalid, you can use null; 2. When a variable has been declared but not yet assigned a value, it will be set to undefined by default; 3. When you need to check whether a variable is empty or undefined, use the strict equality operator "===" to determine whether the variable is null or undefined. .

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

What are the uses of null in java What are the uses of null in java Mar 01, 2024 am 10:10 AM

Usage: 1. Initialize the reference type variable to null, indicating that the variable does not currently point to any object; 2. Set the reference type variable to null, which can release the memory space of the object referenced by the variable and help the garbage collector to recover This object; 3. Use null to check whether a reference is empty. You can avoid the occurrence of NullPointerException by judging whether the reference is null. 4. Use null in conditional judgment to judge whether a reference is empty.

How to set JAVA_HOME in Linux How to set JAVA_HOME in Linux Mar 20, 2024 pm 05:41 PM

Setting JAVA_HOME is essential when you want to develop Java-based applications on a Linux system. JAVA_HOME points to the directory where JDK or JavaDevelopmentKit is installed. Therefore, the JAVA_HOME variable plays a vital role in Java applications as it helps in determining the location of libraries and binaries that need to function correctly. Additionally, the JAVA_HOME variable provides the JDK with access to all programs that require Java. Although it can be configured immediately after installing the JDK or Java Runtime Environment (JRE), most beginners may not know much about the correct way to set it up.

What is the difference between char and varchar in mysql What is the difference between char and varchar in mysql Sep 04, 2023 pm 02:16 PM

The differences between char and varchar in mysql are: 1. CHAR is fixed length, while VARCHAR is variable length; 2. CHAR storage and retrieval efficiency is high, while VARCHAR storage and retrieval efficiency is not high; 3. CHAR takes up storage space, VARCHAR can save storage space.

See all articles