Many people find the following error when inserting data into a database using Php+mysql as a website:
Registration failed! Unknown column ' 1a ' in ' Field list '
It turns out that there is no problem with digital submissions, and other types of char are problematic.
Believe that the small partners and firmly believe that the SQL statement is not written wrong, then the problem is where.
Let's look at my SQL statement:
--inserting data into the user table (user and pass column),
$sql = "INSERT into user (User,pass) VALUES ($user, $pass)";
When we like int data time, SQL executes in the database is
Insert into User (User,pass) values (001,001);
When executing the char model data, however, the SQL statement becomes:
Insert into User (User,pass) values (ABC,ABC);
Now you can see the problem, the reason is the char type to add ' symbol.
Let's change the SQL statement to:
$sql = "INSERT into user (User,pass) VALUES ('". $user. "', '". $pass. "')";
Can.
MySQL Insert string type variable time, need to pay attention to the problem, mom, I think for several hours!!