Is the value transmitted from PHP to mysql null (not null )?

Source: Internet
Author: User
Is the value transmitted from PHP to mysql null (not null )? Hello everyone, I am a beginner in html + css + php + mysql. I just got started for two weeks.
The data transmission of html forms should be based on the name value, right? As follows:



Then write in report. php:
$ Link = mysqli_connect ('localhost', account', 'password', database name') or die ('database connection failed!
');
Echo 'database connected successfully
';

$ Belong = $ _ POST ['belong '];
Echo variable assigned successfully
';

$ Query = "insert into accumulation unit record table (Heritage )".
"VALUES ('$ Belong ')";

$ Result = mysqli_query ($ link, $ query) or die ('insertion record failed!
');
Echo 'form submitted successfully
';
Mysqli_close ($ link );
Echo 'database connection closed successfully
';

The above is part of the code. the database field is long and only one instance is listed.

All the steps indicate that the operation is successful. However, when you check the database, you can find that all the inserted operations are null, null, or empty, and do not even have spaces.

Database and web page code are UTF-8.

By the way, I am a newbie, so many mistakes may be made (for example, I forgot to configure php before. ini). I hope you can tell me all the possible problems you may think of. thank you.


Reply to discussion (solution)

If your form does not have a submit button, how do you submit it?

If your form does not have a submit button, how do you submit it?


Yes. I forgot to paste the code before.
Submit form

The data has been inserted successfully. if no data exists, the database displays null.
However, all values are inserted with null values. when ehco assigned a value to the variable, it was found that the output was empty and there was nothing. it should be a problem with the value assignment.

What are displayed on the page after submission?

What are displayed on the page after submission?




Database connected
Data converted
Form submitted
Database Connection closed

If the data is successfully converted, the original text of the value is successfully assigned.

The simplest one is to output your $ query to see what the SQL statement you are executing and then draw a conclusion.

The simplest one is to output your $ query to see what the SQL statement you are executing and then draw a conclusion.


It is true that the value assignment of the variable has a problem, because the output vlaues is all single quotes.

I don't know why the assignment has a problem.

Then you can check and output $ Belong without your print $ _ POST breakpoint debugging. should you? The reason can be determined step by step.

There is a problem with your database design. let's look at the field length and type! As long as you can get the SQL, there is no problem, that is, there is a problem with your table design.

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.