Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 10:29:35
Original
1076 people have browsed it

通过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());  
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!