Home  >  Article  >  Backend Development  >  Connect to MYSQL database, create database, and create tables through PHP_PHP tutorial

Connect to MYSQL database, create database, and create tables through PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:30:06868browse

Connect to MYSQL database through PHP


$conn = mysql_connect("localhost","root","password") or die("Unable to connect to the database");
mysql_select_db("table",$conn) or die ("Find Data source not found");


---------------------------------- ----------------------------------------
Passed Create MYSQL database with PHP

$conn = mysql_connect("localhost","root","password") or die("Unable to connect to the database");
mysql_create_db("webjx") or die("Unable to create the database" ; -------------------------------------------------- -----------------------


Create mysql table


$conn = mysql_connect("localhost","root","password") or die("Unable to connect to the database"); mysql_select_db("webjx",$conn) or die("Unable to connect to the database") Connect to database webjx"); $sql = "create table webjx_table(
ids integer not null auto_increment,
primary key(ids)
)";
$mysql_query($sq l) or die(mysql_error());




http://www.bkjia.com/PHPjc/509206.html
www.bkjia.com

truehttp: //www.bkjia.com/PHPjc/509206.htmlTechArticleConnect to MYSQL database through PHP $conn=mysql_connect("localhost","root","password")ordie( "Unable to connect to database"); mysql_select_db("table",$conn)ordie("Data source not found"); ---------...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn