Home  >  Article  >  Backend Development  >  mysql空字符串

mysql空字符串

WBOY
WBOYOriginal
2016-06-06 20:07:47971browse

一个php页面处理用户提交过来的数据,其中字段name的处理是判断isset是否存在,再用thinkphp的验证规则require判断是否为空。
mysql一个name字段设置不是null,但表里还是有空字符串记录?
这个问题引起的原因有哪些?

回复内容:

一个php页面处理用户提交过来的数据,其中字段name的处理是判断isset是否存在,再用thinkphp的验证规则require判断是否为空。
mysql一个name字段设置不是null,但表里还是有空字符串记录?
这个问题引起的原因有哪些?

mysql中 null 和 空字符串 是不同的.
mysql 中如果字段值不填,默认为 null
你 name 字段设置为 not null,因此一定要有值才会插入成功,但这个值可以为空字符串.

检查下你的代码吧骚年

你把你插入数据库sql语句打印出来看看
是否已经获取到正确的值
是否字段名与mysql列名一致

Statement:
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