Failed to use the INSERTINTO statement to insert data to the database. Include (conn/conn. php );
If ($ _ POST [submit]) {
$ Code = $ _ POST ['code'];
$ Note = $ _ POST ['note'];
$ Routeway = $ _ POST ['routeway'];
$ Operator = $ _ POST ['operator'];
If ($ code! = "" | $ Note! = "" | $ Routeway! = "" | $ Operator! = ""){
$ SQL = "INSERT INTO code_group (groupNumber, groupCode, groupNote, groupRouteway, groupOperator) VALUES ('', '$ code',' $ note ',' $ routeway ', '$ operator ')";
If (mysql_query ($ SQL )){
Echo "script" alert ('inserted successfully'); script ";
} Else {
Echo "script" alert ('insertion failed'); script ";
}
} Else {
Echo "script" alert ('the content you entered is Null'); script ";
}
}
?>
This is the library settings
Create table 'code _ group '(
'Groupnumber' smallint (6) not null,
'Groupcode' char (8) not null,
'Groupnote' varchar (100) not null,
'Grouprouteway' char (15) not null,
'Groupoperator' char (4) not null,
Primary key ('groupnumber ')
) ENGINE = InnoDB default charset = utf8;
The PHP program can run normally, and the database can be connected normally, that is, the data cannot be inserted. I don't know why.
Reply to discussion (solution)
GroupNumber: a null value is inserted into the primary key.
Run your SQL statement again next time.
Echo mysql_error ();
You can see the cause of the error.
GroupNumber: a null value is inserted into the primary key.
Run your SQL statement again next time.
It is useless to assign a value to the database. the database reports the error "Access denied for user'' @ 'localhost' (using password: NO). However, the database connection password is correct.
Echo mysql_error ();
You can see the cause of the error.
Error: Access denied for user ''@ 'localhost' (using password: NO)
However, the password for connecting to the database is correct and I don't know how to solve this problem.
Access denied for user ''@ 'localhost' (using password: NO)
You do not have a password when connecting.The password for connecting to the database is correct."
Access denied for user ''@ 'localhost' (using password: NO)
You do not have a password when connecting.The password for connecting to the database is correct."
Baidu says that the user name and password do not match. refer to the online method to change the password. I have tried to restart mysql, but I still cannot. Can the moderator tell me how to solve this problem. If there is no problem with the database connection query, the insertion goes wrong.
Thank you for solving the problem.
The problem is that include contains files, include (conn/conn. php); add spaces between include and (conn/conn. php.