How to solve the problem in the middle of the night: Unknowncolumn 'QQ' in 'fieldlist'

Source: Internet
Author: User
Solved by newbie in the middle of the night: How does Unknowncolumnqqinfieldlist solve the problem I encountered during my own exercises? new guy, don't joke... this is the table creation code: & lt ;? Php $ con @ mysql_connect (localhost, root, 123); if ($ con) {mysql_select_db (& quot; employee & qu beginner's solution in the middle of the night: unknown column 'QQ' in 'Field list'
This is a problem I encountered during my own exercises. don't joke, newbie...

This is the table creation code:
$ 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 "the user table is successfully created in the employee database! ";
}
Else echo "an error occurred while creating the table ...";
}
Else
{
Echo "connection error ";
}
?>


Because the difference between int and char is not very clear, char is used.



This is the deal code:
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 "a user with the same name exists. enter the user name again! ";
}
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 "successful insertion record! ";
Else echo "an error occurred while inserting the record! ";
Echo"

";
}
}
Else
{
Echo "No submitted content!
";
}
Echo"
Click here to return ";
?>



I have been studying for a few hours for a newbie at the university. Baidu and Google have not been able to solve the problem for a long time. I hope you can help me with this. thank you very much.

------ Solution --------------------
1. int is an integer. char is a character. Currently, varchar is generally used.
Int: integer data from-2 ^ 31 (-2,147,483,648) to 2 ^ 31-1 (2,147,483,647) (all numbers ). The storage size is 4 bytes.
Char and varchar: the length of the CHAR column is fixed to the length declared during table creation. The length can be any value from 0 to 255. When saving CHAR values, fill in spaces on the right of them to reach the specified length. When the CHAR value is retrieved, the trailing space is deleted. Case-insensitive conversion is not performed during storage or retrieval.
The value in the VARCHAR column is a variable-length string. Length can be set to a value between 0 and 65,535. (The maximum valid length of a VARCHAR is determined by the maximum row size and the character set used. The total length is 65,532 bytes ).

2. the qq field does not exist in the database.


------ Solution --------------------

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)
------ Solution --------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.