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