错误信息:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARSET=utf8' at line 1
CREATE TABLE ysxz_ad
( id
int(10) unsigned NOT NULL AUTO_INCREMENT, title
varchar(100) NOT NULL DEFAULT '', classid
tinyint(1) unsigned NOT NULL DEFAULT '0', hits
int(10) unsigned NOT NULL DEFAULT '0', addtime
int(10) unsigned NOT NULL DEFAULT '0', updatetime
int(10) unsigned NOT NULL DEFAULT '0', image_src
varchar(255) NOT NULL DEFAULT '', image_url
varchar(255) NOT NULL DEFAULT '', image_alt
varchar(100) NOT NULL DEFAULT '', order
smallint(4) unsigned NOT NULL DEFAULT '0', status
tinyint(1) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (id
)) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8
数据库
DROP TABLE IF EXISTS {dbprefix}ad
;
CREATE TABLE {dbprefix}ad
(id
int(10) unsigned NOT NULL AUTO_INCREMENT,title
varchar(100) NOT NULL DEFAULT '',classid
tinyint(1) unsigned NOT NULL DEFAULT '0',hits
int(10) unsigned NOT NULL DEFAULT '0',addtime
int(10) unsigned NOT NULL DEFAULT '0',updatetime
int(10) unsigned NOT NULL DEFAULT '0',image_src
varchar(255) NOT NULL DEFAULT '',image_url
varchar(255) NOT NULL DEFAULT '',image_alt
varchar(100) NOT NULL DEFAULT '',order
smallint(4) unsigned NOT NULL DEFAULT '0',status
tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (id
)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
楼主没有设置编码吧,设置成utf8
order status这些字段名都是关键字,没有加``吧
charset='utf8'应该是这样
在我的mysql workbeach上可以运行,只需要把order字段改一下,我把order字段改为orderNo,结果可以运行,因为与系统定义的order by 冲突,报语法错误!
CREATE TABLE ad (
id int(10) unsigned NOT NULL AUTO_INCREMENT,
title varchar(100) NOT NULL DEFAULT '',
classid tinyint(1) unsigned NOT NULL DEFAULT '0',
hits int(10) unsigned NOT NULL DEFAULT '0',
addtime int(10) unsigned NOT NULL DEFAULT '0',
updatetime int(10) unsigned NOT NULL DEFAULT '0',
image_src varchar(255) NOT NULL DEFAULT '',
image_url varchar(255) NOT NULL DEFAULT '',
image_alt varchar(100) NOT NULL DEFAULT '',
#order smallint(4) unsigned NOT NULL DEFAULT '0',
status tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (id)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
查下order,这个是可以的
没有问题,可以正常执行。。。应该跟sql无关,找其他原因吧。。如图:
服务器mysql版本是4.0的,我用5.1.37的正常。。。
错误提示第一行跑错,你的**Id是自动增长的**,不需要再新增值,把这一条去掉试下