<?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