unknown column field list解决方案

WBOY
Release: 2016-06-13 13:15:37
Original
1313 people have browsed it

unknown column field list

PHP code
 if (empty($username)) {$error[]='Username cannot be empty.';} $query='select user_name from user where user_name="' . $username . '"'; $result=mysql_query($query) or die(mysql_error($db)); if (mysql_num_rows($result)>0) {$error[]='Username has already been used.'; $username='';}
Copy after login

这个是我的代码,出错信息:Unknown column 'tchen13' in 'field list'
tchen13是我post过来的变量


------解决方案--------------------
$query='select user_name from user where user_name="' . $username . '"';
die($query);
第一步,你确定没有别人也在使用,存在注入可能性,也就是你那个username变量里面包含注释加sql语句!
第二步,你确定,同页面没有再查询数据库的地方,因为tchen13是你传过来的变量,也不该搞到字段上去
第三步,输出query语句查看内容是否符合你的期待,看清了,楼上说几次了,你老说是传变量值,如果真是正确值那就不是这句错误,总能证明点东西的,自已动手试试,输出那句SQL语句!
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!