Php operation mysql -- connect to the database to create a table Filling Table

Source: Internet
Author: User

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

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.