varchar字段不能设置default值?解决方法

WBOY
Release: 2016-06-13 10:07:13
Original
1559 people have browsed it

varchar字段不能设置default值?
请教各位:一个极简单的创建数据表的语句:
$query = 'CREATE TABLE IF NOT EXISTS pro_cates (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
fat_id INTEGER UNSIGNED NOT NULL DEFAULT 0,
proname VARCHAR(80) NOT NULL DEFAULT 'unknown',
proname_en VARCHAR(80),
 
PRIMARY KEY (id)
)ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1';
设置了红色的 default 值就会报错,请教这个字段的设置哪里有问题呢?

报错信息是:Parse error: syntax error, unexpected T_STRING in D:\xampp\htdocs\cates_cretable.php on line 9

先谢了!


------解决方案--------------------
DEFAULT "unknown"

语法错误 标点符号
------解决方案--------------------
Parse error: syntax error, unexpected T_STRING
是 php 包的错误,与数据库无关

你在 单引号 分界的串中使用 单引号,难道不需要 转义 吗?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template