Mysql data update and insertion and storage

Source: Internet
Author: User
$ Hostname & quot; localhost & quot; defines the name of the connected mysql server $ username & quot; root & quot; and defines the username $ password & quot; for connection ;; define the password for connection $ linkmys
  1. $ Hostname = "localhost"; // defines the name of the connected mysql server
  2. $ Username = "root"; // defines the user name used for connection.
  3. $ Password = ""; // defines the password used for connection.
  4. $ Link = mysql_connect ($ hostname, $ username, $ password); // connect to the mysql server
  5. Mysql_select_db ("test", $ link); // select a database
  6. // Define an SQL statement
  7. $ SQL _str = "update friends set name = 'Andy 'where id = 1 ";
  8. Mysql_query ($ SQL _str) or die ("error! "); // Execute SQL query
  9. Echo mysql_info ($ link );
  10. // Define the SQL statement and perform the modification operation
  11. $ SQL _str = "insert into friends (name, sex, birthday, address) values ('Chen Jing Qiu ', 'male', '2017-08-23', 'day marks ')";
  12. Mysql_query ($ SQL _str) or die ("error! "); // Execute SQL query
  13. Printf ("The id value of the last insert operation is: % dn", mysql_insert_id (); // return the id value affected by insert

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.