Mysql insert data tutorial

Source: Internet
Author: User
Tags mysql code mysql insert

Mysql saves data that web developers use every day. Let's take a look at the tutorial on using the insert statement.

When data is put into a MySQL table, it is called inserting data. When inserting data, it is important to remember the exact name and type of the table column. If you try to create a 500-character essay to become a column and only accept the integer size 3, you will end a nasty error!


Insert data to your table
Now that you have created your table, let's put some data to the puppy! This is the data inserted in PHP/MySQL code as an "example". We learned how to create a table in the past.

<? Php
// Make a MySQL Connection
Mysql_connect ("localhost", "admin", "1 admin") or die (mysql_error ());
Mysql_select_db ("test") or die (mysql_error ());

// Insert a row of information into the table "example"
Mysql_query ("insert into example
(Name, age) VALUES ('tiancmellowman ', '23 ')")
Or die (mysql_error ());

Mysql_query ("insert into example
(Name, age) VALUES ('sandy Smith ', '21 ')")
Or die (mysql_error ());

Mysql_query ("insert into example
(Name, age) VALUES ('bobby Wallace ', '15 ')")
Or die (mysql_error ());

Echo "Data Inserted! ";

?>

Displayed

Data inserted

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.