先mysql_connect()到mysql再做mysql_query()的相关操作。
创新互联建站从2013年成立,先为昌江黎族等服务建站,昌江黎族等地企业,进行企业商务咨询服务。为昌江黎族企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
====================================================================
?php
$server = "localhost";
$username = "root";
$password = "";
$database = "myabc";
$ranks = array(
1="newbie",
2="new member",
3="member",
4="high member",
5="very high member",
6="supreme member",
7="ultra member",
8="godlike member",
9="god member",
10="low god",
11="medium god",
12="high god",
13="very high god",
14="supreme god",
15="ultra god",
16="perfect"
);
$couldNotOpenDatabase = "Could not open databaseBR\n please check your settings in config.php";
$couldNotConnectMysql="Could not connect Mysql!";
$conn=mysql_connect($server,$username,$password) or die ($couldNotConnectMysql);
if (mysql_select_db($database,$conn))
{//数据库存在,做相应操作
}
else
{//数据库不存在,创建一个,并做相应操作
$query = "CREATE DATABASE $database";
$result = mysql_query($query);
mysql_select_db($database,$conn)or die ($couldNotOpenDatabase);
}
?
mysql_select_db("table"
,conn)
or
die
("找不到数据源");
-----------------------------------------------------------------------
通过PHP创建MYSQL数据库
conn
=
mysql_connect("localhost","root","password")
or
die("无法连接数据库");
mysql_create_db("dwww")
or
die("无法创建数据库");
sqlstr
=
"create
database
other_dwww";
----------------------------------------------------------------------------
创建mysql的表
conn
=
mysql_connect("localhost","root","password")
or
die("无法连接数据库");
mysql_select_db("dwww",conn)
or
die("无法连接数据库dwww");
sql
=
"create
table
dwww_table(
//判断数组
colors
=
array(red,
blue,
green);
if(is_array(colors))
{
print(colors
is
an
array.br);
}
//双精度数判断
Temperature
=
15.23;
if(is_double(TemperatuPHP在线视频教程
PHP视频教程打包下载php自学视频教程
PHP100视频教程
PHP视频教程,LAMP视频教程PHP从入门到精通视频教程
PHP+MYSQL网站设计入门实践
PHP100视频教程DVD光盘-第二季
PHP?
?
require ( "adodb.inc.php "); //load code common to ADODB
$db = ADONewConnection( "ado_access ");
$access = 'test.mdb '; //dbname
$myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0; '. 'DATA SOURCE= '. $access . '; '; 'USER ID=;PASSWORD=; ';
$db- PConnect($myDSN, " ", " ", " ") ;
$sql= "CREATE TABLE test...... "; //create the table
$rs=$db- Execute($sql);
for(.....){
$db- Execute( "insert into test ...... "); //insert the data
}
//adodb.inc.php你google下,原来地址已失效
?