语法:create database database_name
在创建数据库之前我们首先用mysql_query()函数发送数据库链接请求,成功后在通过create database语句创建数据库
<?php
$con = mysql_connect("localhost","root","");
if (!$con){
die('Could not connect: ' . mysql_error());
}
if (mysql_query("create database test_db",$con)){
echo "Database created";
}
else{
echo "Error creating database: " . mysql_error();
}
mysql_close($con);
?>