Php inserts a null value into mysql.-php Tutorial

Source: Internet
Author: User
Php inserts null values into mysql.

The SQL statement is written as "insert into uer (id, name, pass) values ('', 'Lily', '123 ')"
Where, id is the primary key, auto-increment.

I remember setting it in the configuration file so that a null value can be passed during php execution, but I forgot where it was set. please let me know.


Reply to discussion (solution)

How do you set a null value for auto-increment? Sao Nian


"Insert into uer (name, pass) values ('Lily', '123 ')"

The inserted null values of id sub-growth must have an error.
Delete it, that is, insert into uer (name, pass) values ('Lee 4', '123 ')

Id auto-increment. it must be int type! How can I add strings?
The id does not need to be written.
Insert into uer (name, pass) values ('Lee 4', '123 ')

Yes. I have set this item before. now I forget which item in the configuration file. I have done this in the php100 video, but I didn't know where to set it.

I don't know what you're talking about.
Isn't your code?

Yes. I have set this item before. now I forget which item in the configuration file. I have done this in the php100 video, but I didn't know where to set it.
I have forgotten it.

Solve the problem. in the mysql configuration file, modify the settings where null values cannot be passed by default.
The default value is SQL-mode = "STRICT_TRANS_TABLES, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION ",

Change it to SQL-mode = "NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION"

Ah, I really cannot afford it. why do I have to change it? For this one, modify the configuration?
What can you do if you cannot change the single-hanging virtual space on the Internet,

Learning stage, various research

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.