The value of PHP transferred to MySQL is empty (not null)?

Source: Internet
Author: User
Tags what sql
Hello everyone, I am a novice html+css+php+mysql, just started two weeks.
Is the data transfer of the HTML form to be through the name value? As follows:



Then write in the report.php:
$link =mysqli_connect (' localhost ', account ', ' password ', database name ') or Die (' Connect database failed!
');
echo ' Connect to database successfully
';

$Belong =$_post[' Belong '];
Echo Variable Assignment succeeded
';

$query = "INSERT into a stacked unit record table (belonging to a relic)".
"VALUES (' $Belong ')";

$result =mysqli_query ($link, $query) or Die (' Insert record failed!
');
Echo ' submits the form successfully
';
Mysqli_close ($link);
Echo ' Closed database connection succeeded
';

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

But all the steps are prompt success, but when you look at the database, you find that all the insertions are null, NOT NULL, or empty, not even a space.

Both the database and the Web page are encoded in UTF-8.

I am a novice, so a lot of mistakes may be committed (such as forget to configure php.ini), I hope that you can think of the great God may have a problem in the place to tell me, thank you


Reply to discussion (solution)

Your form does not have a submit button, so how did you submit it?

Your form does not have a submit button, so how did you submit it?


Yes, I forgot to paste the code before.
Submit Form

The data has been inserted successfully and the database shows NULL when there is no data.
But is inserted all is empty value, I ehco the next assignment variable, found that the output is also empty nothing, it should be assigned to this piece where there is a problem.

What does the page show after submission?

What does the page show after submission?




Connection Database Successful
Data Conversion Success
Submit the form successfully
Close database connection succeeded

That data conversion success is the original text of the assignment success

The simplest of you to output the following your $query see what SQL statements you execute and then make a conclusion

The simplest of you to output the following your $query see what SQL statements you execute and then make a conclusion


It is true that there is a problem with the variable assignment because the vlaues of the output is all single quotes.

I don't know why the assignment is going to go wrong.

Then you go up to the bottom of the $belong $Belong without you in print $_post breakpoint debugging you should? Step-up and finally you can determine why.

You have a database design problem, look at the field length and type! As long as you can get to, SQL, no problem, is the design of your table has a problem

  • Related Article

    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.