当前位置: 首页 > >

建好的数据库放在php,PHP 创建数据库练*

发布时间:

header("Content-type:text/html","Charset=UTF-8");


$file="config/config.php";


if(is_writable($file)!=null){


echo "文件可写入
";


}else{


echo "文件不可写|";


exit();


}


if(isset($_POST["install"])){


$string = "";


$string .="$mysql_host="$_POST[db_host]";
";


$string .="$mysql_user="$_POST[db_user]";
";


$string .="$mysql_pass="$_POST[db_pass]";
";


$string .="$mysql_dbname="$_POST[db_dbname]";
";


$string .="$mysql_tag="$_POST[db_tag]";
";


$string .= "?>";


if($f=fopen($file,"w+")){


echo "文件已打开|";


if(fwrite($f,$string)===false){


echo "文件无法与入";


exit();


}


else{


echo "文件写入成功";


include_once($file);


if($link = mysql_connect($mysql_host,$mysql_user,$mysql_pass)or die("数剧库链接失败")){


mysql_query("CREATE DATABASE `$mysql_dbname` CHARACTER SET utf8 COLLATE utf8_general_ci");


if(mysql_select_db($mysql_dbname)){


echo "|数据库创建成功|";


$mysql_add_table[]= "CREATE TABLE `".$mysql_tag."j1`(


`id` int(8) unsigned NOT NULL AUTO_INCREMENT,


`username` varchar(15)? CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,


`types` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,


PRIMARY KEY (`id`)


);";


$mysql_add_table[]= "CREATE TABLE `".$mysql_tag."j2`(


`id` int(8) unsigned NOT NULL AUTO_INCREMENT,


`username` varchar(15)? CHARACTER SET utf8 COLLATE







相关资源:php提交表单到mysql数据库实例



友情链接: