How to add data to mysql

Source: Internet
Author: User
About how to add data INSERTINTOroom (roomid, name, id1, id2) values ('1', '20170101', '$ _ POST [id1]', '$ _ POST [id2]') $ _ POST [id1], $ _ POST [id2] indicates a value, not an ID. how can this problem be solved ?, $ _ POST [id1], $ _ POST [about adding data to mysql
Insert into room (roomid, name, id1, id2) values ('1', '000000', '$ _ POST [id1]', '$ _ POST [id2]')

$ _ POST [id1], $ _ POST [id2] is a value, not an ID. how can this problem be solved?

------ Solution --------------------
$ _ POST [id1], $ _ POST [id2] indicates that the value is not an id concept.

Is the value in SQL a variable name, not a value.
Insert into room (roomid, name, id1, id2) values ('1', '000000', '{$ _ POST [id1]}', '{$ _ POST [id2]}')

Or

"Insert into room (roomid, name, id1, id2) values ('1', '123 ','". $ _ POST [id1]. "','". $ _ POST [id2]. "')"
------ Solution --------------------
What does it mean ??
------ Solution --------------------
The IDs of the two tables cannot be inserted in an insert statement at the same time.
If the id is set to auto_increment, you do not need to insert the id, and duplicate values cannot be inserted.
If not set to auto-growth:
SQL = "insert into room (roomid, name, id1) values (". $ _ POST ['roomid']. ",'". $ _ POST ['name']. "',". $ _ POST ['id1']. ")";
You can query multiple tables.

------ Solution --------------------
$ _ POST [id1], $ _ POST [id2] is his value

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.