if(!is_writable('config.php')){
成都创新互联公司专业为企业提供海林网站建设、海林做网站、海林网站设计、海林网站制作等企业网站建设、网页设计与制作、海林企业网站模板建站服务,十载海林做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
emMsg('配置文件(config.php)不可写。如果您使用的是Unix/Linux主机,请修改该文件的权限为777。如果您使用的是Windows主机,请联系管理员,将此文件设为可写');
}
if(!is_writable(EMLOG_ROOT.'/content/cache')){
emMsg('缓存文件不可写。如果您使用的是Unix/Linux主机,请修改缓存目录 (content/cache) 下所有文件的权限为777。如果您使用的是Windows主机,请联系管理员,将该目录下所有文件设为可写');
}
$config = "?php\n"
."//mysql database address\n"
."define('DB_HOST','$db_host');"
."\n//mysql database user\n"
."define('DB_USER','$db_user');"
."\n//database password\n"
."define('DB_PASSWD','$db_pw');"
."\n//database name\n"
."define('DB_NAME','$db_name');"
."\n//database prefix\n"
."define('DB_PREFIX','$db_prefix');"
."\n//auth key\n"
."define('AUTH_KEY','".getRandStr(32).md5($_SERVER['HTTP_USER_AGENT'])."');"
."\n//cookie name\n"
."define('AUTH_COOKIE_NAME','EM_AUTHCOOKIE_".getRandStr(32,false)."');"
."\n";
$fp = @fopen('config.php', 'w');
$fw = @fwrite($fp, $config);
if (!$fw){
emMsg('配置文件(config.php)不可写。如果您使用的是Unix/Linux主机,请修改该文件的权限为777。如果您使用的是Windows主机,请联系管理员,将此文件设为可写');
}
fclose($fp);
//密码加密存储
$PHPASS = new PasswordHash(8, true);
$adminpw = $PHPASS-HashPassword($adminpw);
$dbcharset = 'utf8';
$type = 'MYISAM';
$table_charset_sql = $DB-getMysqlVersion() '4.1' ? 'ENGINE='.$type.' DEFAULT CHARSET='.$dbcharset.';' : 'ENGINE='.$type.';';
if ($DB-getMysqlVersion() '4.1' ){
$DB-query("ALTER DATABASE `{$db_name}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;", true);
}
$widgets = Option::getWidgetTitle();
$sider_wg = Option::getDefWidget();
$widget_title = serialize($widgets);
$widgets = serialize($sider_wg);
define('BLOG_URL', getBlogUrl());
$sql = "
DROP TABLE IF EXISTS {$db_prefix}blog;
CREATE TABLE {$db_prefix}blog (
gid int(10) unsigned NOT NULL auto_increment,
title varchar(255) NOT NULL default '',
date bigint(20) NOT NULL,
content longtext NOT NULL,
excerpt longtext NOT NULL,
alias VARCHAR(200) NOT NULL DEFAULT '',
author int(10) NOT NULL default '1',
sortid int(10) NOT NULL default '-1',
type varchar(20) NOT NULL default 'blog',
views int(10) unsigned NOT NULL default '0',
comnum int(10) unsigned NOT NULL default '0',
attnum int(10) unsigned NOT NULL default '0',
top enum('n','y') NOT NULL default 'n',
sortop enum('n','y') NOT NULL default 'n',
hide enum('n','y') NOT NULL default 'n',
checked enum('n','y') NOT NULL default 'y',
allow_remark enum('n','y') NOT NULL default 'y',
password varchar(255) NOT NULL default '',
template varchar(255) NOT NULL default '',
PRIMARY KEY (gid),
KEY date (date),
KEY author (author),
KEY sortid (sortid),
KEY type (type),
KEY views (views),
KEY comnum (comnum),
KEY hide (hide)
)".$table_charset_sql."
INSERT INTO {$db_prefix}blog (gid,title,date,content,excerpt,author,views,comnum,attnum,top,sortop,hide,allow_remark,password) VALUES (1, '欢迎使用emlog', '".time()."', '恭喜您成功安装了emlog,这是系统自动生成的演示文章。编辑或者删除它,然后开始您的创作吧!', '', 1, 0, 0, 0, 'n', 'n', 'n', 'y', '');
DROP TABLE IF EXISTS {$db_prefix}attachment;
CREATE TABLE {$db_prefix}attachment (
aid int(10) unsigned NOT NULL auto_increment,
blogid int(10) unsigned NOT NULL default '0',
filename varchar(255) NOT NULL default '',
filesize int(10) NOT NULL default '0',
filepath varchar(255) NOT NULL default '',
addtime bigint(20) NOT NULL default '0',
width int(10) NOT NULL default '0',
height int(10) NOT NULL default '0',
mimetype varchar(40) NOT NULL default '',
thumfor int(10) NOT NULL default 0,
PRIMARY KEY (aid),
KEY blogid (blogid)
)".$table_charset_sql."
DROP TABLE IF EXISTS {$db_prefix}comment;
CREATE TABLE {$db_prefix}comment (
cid int(10) unsigned NOT NULL auto_increment,
gid int(10) unsigned NOT NULL default '0',
pid int(10) unsigned NOT NULL default '0',
date bigint(20) NOT NULL,
poster varchar(20) NOT NULL default '',
comment text NOT NULL,
mail varchar(60) NOT NULL default '',
url varchar(75) NOT NULL default '',
ip varchar(128) NOT NULL default '',
hide enum('n','y') NOT NULL default 'n',
PRIMARY KEY (cid),
KEY gid (gid),
KEY date (date),
KEY hide (hide)
)".$table_charset_sql."
DROP TABLE IF EXISTS {$db_prefix}options;
CREATE TABLE {$db_prefix}options (
option_id INT( 11 ) UNSIGNED NOT NULL auto_increment,
option_name VARCHAR( 255 ) NOT NULL ,
option_value LONGTEXT NOT NULL ,
PRIMARY KEY (option_id),
KEY option_name (option_name)
)".$table_charset_sql."
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('blogname','点滴记忆');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('bloginfo','使用emlog搭建的站点');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('site_title','');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('site_description','');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('site_key','emlog');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('log_title_style','0');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('blogurl','".BLOG_URL."');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('icp','');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('footer_info','');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('admin_perpage_num','15');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('rss_output_num','0');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('rss_output_fulltext','y');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('index_lognum','10');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('index_comnum','10');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('index_twnum','10');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('index_newtwnum','5');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('index_newlognum','5');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('index_randlognum','5');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('index_hotlognum','5');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('comment_subnum','20');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('nonce_templet','default');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('admin_style','default');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('tpl_sidenum','1');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('comment_code','n');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('comment_needchinese','y');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('comment_interval',60);
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('isgravatar','y');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('isthumbnail','y');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('att_maxsize','20480');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('att_type','rar,zip,gif,jpg,jpeg,png,txt,pdf,docx,doc,xls,xlsx');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('att_imgmaxw','420');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('att_imgmaxh','460');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('comment_paging','y');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('comment_pnum','10');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('comment_order','newer');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('login_code','n');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('reply_code','n');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('iscomment','y');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('ischkcomment','y');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('ischkreply','n');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('isurlrewrite','0');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('isalias','n');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('isalias_html','n');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('isgzipenable','n');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('isxmlrpcenable','n');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('ismobile','n');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('isexcerpt','n');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('excerpt_subnum','300');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('istwitter','y');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('istreply','n');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('topimg','content/templates/default/images/top/default.jpg');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('custom_topimgs','a:0:{}');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('timezone','8');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('active_plugins','');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('widget_title','$widget_title');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('custom_widget','a:0:{}');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('widgets1','$widgets');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('widgets2','');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('widgets3','');
INSERT INTO {$db_prefix}options (option_name, option_value) VALUES ('widgets4','');
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?
首先我要登陆php MyAdmin
创建数据库图php MyAdmin右边窗口填写数据库名称点创建即 例我创建名字:cncmstest 数据库
创建功提示:
点击左角主页按钮返php MyAdmin主界面:
主界面右边点击权限创建数据库帐号
权限页面我点击添加新用户
该页面我填写要创建数据库用户名该用户访问范围及密码图我填写用户名:cncmsuser该数据库用户允许本机访问主机项选择本;密码我使用自点面Generate随机密码点Copy自填写密码框
面框都选直接拉页面面点执行即创建新用户
数据库用户创建功返页面:
重要步设置该用户数据库访问权限
数据库用户添加功返页面直接设置权限我选择按数据库指定权限:图数据库列表选择我刚刚创建cncmstest即自进入该数据库权限设置页面图权限设置我数据、结构两列权限全部选管理权限都要选点执行即
建立数据表,得是你在cmd窗口或者phpmyadmin、navicat for mysql这类终端软件里进行操作。建立数据表的指令是create table xxx ();
连接数据库使用php封装好的一个函数mysql_connect();
例如:
mysql_connect('127.0.0.1','root','root');
这样的语句来连接,因为连接数据库会生成连接标识资源,你把这个资源赋给一个新变量
$active_connection_sort = mysql_connect('127.0.0.1','root','root');
这样你拿着新变量去玩别的也好下手。
括号中间都是参数,第一个是连接地址,比如localhost,但我个人建议还是127.0.0.1省得还得来一步解析,第二个参数是用户名,第三个参数是密码,都用英文单括号括上。参数和参数之间用英文逗号间隔起来。
用框架做久了这个东西都容易忘,我也是凭记忆写的,你试试看这个能不能过关。
创建数据库:create database 数据库名
创建数据表:
CREATE TABLE `users` (
`id` tinyint(10) auto_increment primary key NOT NULL,
`username` varchar(30) NOT NULL,
`age` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
执行这两个sql语句就行
THINKPHP貌似没有自己的方法创建数据表。
能想到的有:在thinkphp里执行原生的创建表语句。