PHP Operation mysql--Connection database CREATE table fill table

Source: Internet
Author: User

<?php/*** Created by Phpstorm.* User:administrator* Date:2015/3/31* time:14:40 */Header("Content-type:text/html;charset=utf8");//declaring the encoding format$conn=mysql_connect("localhost","Root","AAAAAA") or die("Database connection Error".Mysql_errno());//ConnectionSQL//$createTable =mysql_query ("CREATE Database Phptest", $conn) or Die ("CREATE TABLE Error:". Mysql_errno ());//Create a databasemysql_select_db("Phptest",$conn);//fromSQLSelect Database inmysql_query(' SET NAMES UTF8 ') or die('CharSet Set Error'.Mysql_error());//set the input character set encoding/* $sql = "CREATE TABLE txt (//sqlcommand to create a table and populate the fieldsID TINYINT (2) UNSIGNED not NULL auto_increment,username varchar (+),Password char (+),Email varchar (+),regdate Int (10),//use int to save timestampPRIMARY KEY (ID))";mysql_query ($sql) or Die ("Error Creating table:". Mysql_errno ());//execution of the CREATE tableSQLinstruction*/$regdate=  Time(); //Get time stamp$input=INSERT into txt (username, password, email, regdate) VALUES ('Xiao Wang' , ' passwords ', ' [email protected] ',$RegDate)";//sqlTo add a data statementmysql_query($input,$conn) or die("Add data error:".Mysql_errno());//Execute the Add dataSQLinstruction?>

PHP Operation mysql--Connection database CREATE table fill table

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.