What is the problem with the phpmysqlinsert statement?

Source: Internet
Author: User
The phpcms system has an SQL statement (add article content). I recorded the SQL statements it executes into the file and found that there is a field that is not inserted or has no default value, I don't know how the SQL statement is successfully executed. If I execute the statement in phpmyadmin, an error is reported. The following SQL statement...

The phpcms system has an SQL statement (add article content). I recorded the SQL statements it executes into the file and found that there is a field that is not inserted or has no default value, I don't know how the SQL statement is successfully executed. If I execute the statement in phpmyadmin, an error is reported.

The following SQL statement does not contain the typeid field. This field is non-empty and has no default value. (The data table name has been replaced)

Insert into 'somedb '. 'News' ('hascode', 'style', 'thumb', 'inputtime', 'islink', 'catid', 'title', 'keyword', 'description ', 'posids', 'status', 'updatetime', 'username', 'sysadd') VALUES ('0', '','', '123', '0 ', '1', 'let's see what's going on here? ',' The case. 'Let's take a look at the situation? ', '0', '99', '000000', 'wenhua', '1 ')

The above error is that the same SQL statement is executed in phpmyadmin, but it can be successfully executed in phpcms. What is the problem?

Reply content:

The phpcms system has an SQL statement (add article content). I recorded the SQL statements it executes into the file and found that there is a field that is not inserted or has no default value, I don't know how the SQL statement is successfully executed. If I execute the statement in phpmyadmin, an error is reported.

The following SQL statement does not contain the typeid field. This field is non-empty and has no default value. (The data table name has been replaced)

Insert into 'somedb '. 'News' ('hascode', 'style', 'thumb', 'inputtime', 'islink', 'catid', 'title', 'keyword', 'description ', 'posids', 'status', 'updatetime', 'username', 'sysadd') VALUES ('0', '','', '123', '0 ', '1', 'let's see what's going on here? ',' The case. 'Let's take a look at the situation? ', '0', '99', '000000', 'wenhua', '1 ')

The above error is that the same SQL statement is executed in phpmyadmin, but it can be successfully executed in phpcms. What is the problem?

Post the table definition to us:

Show create table name;

The error is that the typeid field of the zhenbenling. news table does not have a default value (and it does not allow null values). You must provide this field value when inserting it! Even ''!

For your convenience, modify the constraints in this column:

use zhenbenling;alter table news change typeid typeid smallint(5) NOT NULL DEFAULT '';

Are you sure you can find the insert record in phpcms? It is normal for phpadmin to report an error.

Set the default value for the typeid field or leave it blank.

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.