Php operation mysql -- connect to the database to create a table Filling Table
<? Php/*** Created by PhpStorm. * User: Administrator * Date: 2015/3/31 * Time: 14:40 */header ("Content-Type: text/html; charset = utf8 "); // declare the encoding format $ conn = mysql_connect ("localhost", "root", "aaaaaa") or die ("database connection error ". mysql_errno (); // connect to SQL // $ createTable = mysql_query ("create database phpTest", $ conn) or die ("Table creation error :". mysql_errno (); // create the database mysql_select_db ("phpTest", $ conn); // select the database mysql_query ('set NAMES utf8' from SQL' ) Or die ('character set setting error '. mysql_error (); // sets the input character set encoding/* $ SQL = "create table txt (// SQL creates a TABLE and fills in the field's command id TINYINT (2) unsigned not null AUTO_INCREMENT, username varchar (20), password char (32), email varchar (40), regdate int (10 ), // use int to save the timestamp primary key (id) "; mysql_query ($ SQL) or die (" Table creation error :". mysql_errno (); // execute the SQL command */$ regdate = time () for creating a table; // obtain the timestamp $ input = "INSERT INTO txt (username, password, email, regdate) VALU ES ('wang ', 'Password', '1970 @ 163.com', $ regdate) "; // SQL add data statement mysql_query ($ input, $ conn) or die ("add data error :". mysql_errno (); // execute the SQL command for adding data?>