MySQL Insert data tutorial

Source: Internet
Author: User
Tags mysql code mysql insert

When data is placed in a MySQL table is called insert data. When inserting data, it is important to remember the exact name and type of the column of the table. If you try to build a 500 word composition into a column that accepts only the size of an integer 3, you will end up with a nasty bug!


Insert data into your table
Now that you have created your form, let's put some data on the puppy! This is the Php/mysql code inserted in the data for "example" we created the table in the past lesson.

<?php
Make a MySQL Connection
mysql_connect ("localhost", "admin", "1admin") 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 (' Timmy mellowman ', ' 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 as

Data inserted

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.