Heim  >  Artikel  >  Backend-Entwicklung  >  通过PHP连接MYSQL数据库、创建数据库、创建表_PHP教程

通过PHP连接MYSQL数据库、创建数据库、创建表_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:30:06830Durchsuche

通过PHP连接MYSQL数据库 


      $conn = mysql_connect("localhost","root","password") or die("无法连接数据库");
      mysql_select_db("table" ,$conn) or die ("找不到数据源");


-----------------------------------------------------------------------
 通过PHP创建MYSQL数据库 

      $conn = mysql_connect("localhost","root","password") or die("无法连接数据库");
      mysql_create_db("webjx") or die("无法创建数据库");
      $sqlstr = "create database other_webjx";
      mysql_query($sqlstr) or die("无法创建,一般请检查权限什么的");

----------------------------------------------------------------------------
  创建mysql的表 

      $conn = mysql_connect("localhost","root","password") or die("无法连接数据库");
      mysql_select_db("webjx",$conn) or die("无法连接数据库webjx");
      $sql = "create table webjx_table(
    ids integer not null auto_increment ,
    primary key(ids)
    )";
      $mysql_query($sql) or die(mysql_error());  

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/509206.htmlTechArticle通过PHP连接MYSQL数据库 $conn=mysql_connect("localhost","root","password")ordie("无法连接数据库"); mysql_select_db("table",$conn)ordie("找不到数据源"); ---------...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn