Home > Backend Development > PHP Tutorial > mysql_affected_rows的返回值

mysql_affected_rows的返回值

WBOY
Release: 2016-06-23 14:02:27
Original
1188 people have browsed it

$result=mysql_query("update user set sex='{$_clean['sex']}',            						face='{$_clean['face']}',            						qq='{$_clean['qq']}',            						email='{$_clean['email']}',            						url='{$_clean['url']}'            						where    username='{$_COOKIE['username']}'",$conn);
Copy after login


为什么mysql_affected_rows()的返回是0,执行结果是正确的,按道理来说不是返回受影响的行数1吗?

没办法只能用 $result的值判断是否成功


回复讨论(解决方案)

mysql_affected_rows 返回 0,表示没有记录被修改
但 update 指令本身是正确的

可是结果的确被修改了啊!

但我也没有看到你执行 mysql_affected_rows 啊

不好意思,是我自己的错,在前期往数据库里写数据的时候,不小心username有两个值是一样的,所以mysql_affected_rows()为2,不小心啊!

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