Connect to the MYSQL database through PHP, create a database, and create a table
Source: Internet
Author: User
Connect to the MYSQL database through PHP & nbsp; $ conn & nbsp; mysql_connect (localhost, root, password) & nbsp; or & nbsp; die (unable to connect to the database); & nbsp; & nb
Connect to the MYSQL database through PHP
$ Conn = mysql_connect ("localhost", "root", "password") or die ("unable to connect to database ");
Mysql_select_db ("table", $ conn) or die ("data source not found ");
-----------------------------------------------------------------------
Create a MYSQL database using PHP
$ Conn = mysql_connect ("localhost", "root", "password") or die ("unable to connect to database ");
Mysql_create_db ("webjx") or die ("unable to create database ");
$ Sqlstr = "create database other_webjx ";
Mysql_query ($ sqlstr) or die ("cannot be created, please check the permission or something ");
----------------------------------------------------------------------------
Create a mysql table
$ Conn = mysql_connect ("localhost", "root", "password") or die ("unable to connect to database ");
Mysql_select_db ("webjx", $ conn) or die ("unable to connect to the database webjx ");
$ SQL = "create table webjx_table (
Ids integer not null auto_increment,
Primary key (ids)
)";
$ Mysql_query ($ SQL) or die (mysql_error ());
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.