Beginner Midnight Solver: Unknown column ' qq ' in ' field list ' How to solve

Source: Internet
Author: User
Beginner Midnight Solver: Unknown column ' qq ' in ' field list ' How to solve
This is my own practice when the problem encountered, novice, don't joke ...

This is the code that builds the table:
[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 (TEN) is not NULL,
QQ Char (+) is not NULL,
Tel Char (+) is not NULL,
Email char () NOT NULL,
Social_security char () NOT NULL,
Postcode char (a) is not NULL,
Home_add char (-) NOT NULL,
Home_tel char () NOT NULL,
Residence_registration Char (TEN) is not NULL,
Nation_place char (+) NOT NULL
)";
$do =mysql_query ($sql, $con);
if ($do)
{
echo "Successfully created the user table in the employee database!";
}
else echo "Building the table with errors ...";
}
Else
{
echo "Connection error";
}
?>


Because the division is not very clear the difference between int and char, so it is all with char.



This is the code for 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 "There is a user with the same name, re-enter the user name!";
}
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 "successfully inserted record! ";
else echo "Insert record failed! ";
echo "

";
}
}
Else
{
echo "did not submit content!"
";
}
echo "
Point here to return ";
?>



College Novice, studied for several hours, Baidu Google for a long time can not solve, I hope there are experts to help me, thank you very much.

------Solution--------------------
1.int is an integer type char is a character type and is now generally used with varchar
int: integer data (all numbers) from -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647). Storage size is 4 bytes
The length of the char and Varchar:char columns is fixed to the length declared when the table was created. The length can be any value from 0 to 255. When you save a char value, a space is filled to the right of them to reach the specified length. When a char value is retrieved, the trailing space is removed. No case conversions are made during the storage or retrieval process.
The value in the varchar column is a variable-length string. The length can be specified as a value between 0 and 65,535. (The maximum effective length of varchar is determined by the maximum row size and the character set used.) The overall maximum length is 65,532 bytes).

2.QQ This field does not exist in the database


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

SQL code
create TABLE personal_data (id int (5) NOT NULL AUTO_INCR Ement primary Key,name char (TEN) not null,qq char (+) not Null,tel char (+) not null,email char (a) not Null,social_securit y char (x) not Null,postcode char (a) not null,home_add char (+) not Null,home_tel char (+) not null,residence_registratio n Char (Ten) not null,nation_place char (+) 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.