Could you tell me how to insert a variable! Solution
Source: Internet
Author: User
Could you tell me how to insert a variable! & Lt ;? Phpinclude (& quot; conn. php & quot;); $ name =$ _ POST [& quot; username & quot;]; $ psw =$ _ POST [& quot; userpsw & quot;]; $ email = $ _ POST [& ask Daxia for instructions on how to insert variables!
$ Name = $ _ POST ["username"];
$ Psw = $ _ POST ["userpsw"];
$ Email = $ _ POST ["email"];
$ Qq =$ _ POST ["qq"];
Echo $ name;
Echo $ psw;
Echo $ email;
Echo $ qq;
$ Insert = mysql_query ("insert into user (name, psw, email, qq) values ($ name, $ psw, $ email, $ qq )");
If (! $ Insert ){
Echo "insertion failed! ";
}
?>
The preceding code inserts a form submission information.
Echo $ name;
Echo $ psw;
Echo $ email;
Echo $ qq;
This section can be output. that is to say, there is no problem with form submission? However, the insert operation has always failed and no data is inserted in the database. what is the problem? (I am a beginner. thank you for your understanding ~~ There are not many points, online reply ing !)
------ Solution --------------------
SQL adds all your variables to ''. if the data table is of the int value or other types, you do not need to add any other types''
The database connection is normal, because I have been using this. conn to connect to the database, saving all the time to write. The query can be implemented.
------ Solution --------------------
Send your table structure. I will see what encoding is. set the encoding to be consistent.
------ Solution --------------------
Discussion
How to send a picture ...... It seems that there are no widgets installed.
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.