该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
改为
$con=mysql_connect('localhost','root','');
if(!$con)
die('连接数据库失败');
mysql_select_db('comment_db',$con);
$mysql_sql="create table comment_tab(
id mediumint unsigned NOT NULL auto_increment,
nickname char(16) NOT NULL default '',
email varchar(60) default NULL,
comment text NOT NULL,
createtime int(10) unsigned default '0',
reply text ,
replytime int(10) ,
PRIMARY KEY(id))";
if(!mysql_query($mysql_sql,$con))
die('创建表格失败');
?>
实际上就是把 PRIMARY KEY('id') 改为 PRIMARY KEY(id)
然后如果想加引擎 编码之类的 可以这样写
$con=mysql_connect('localhost','root','');
if(!$con)
die('连接数据库失败');
mysql_select_db('comment_db',$con);
$mysql_sql="create table comment_tab(
id mediumint unsigned NOT NULL auto_increment,
nickname char(16) NOT NULL default '',
email varchar(60) default NULL,
comment text NOT NULL,
createtime int(10) unsigned default '0',
reply text ,
replytime int(10) ,
PRIMARY KEY(id)
)engine=MyISAM default charset=utf8 auto_increment=1;";
if(!mysql_query($mysql_sql,$con))
die('创建表格失败');
?>