Home > Backend Development > PHP Tutorial > 通过 _GET方法没能拿到数据

通过 _GET方法没能拿到数据

WBOY
Release: 2016-06-23 13:28:29
Original
1025 people have browsed it

如下图,通过get拿到用户名,在另一个页面并没有拿到,请问是什么原因?


回复讨论(解决方案)

你前面从数据库取出的是password字段,而你下面却$name = $row['name'],所以并没有取出name字段,你的sql语句里变成

SELECT  password,name FROM admin WHERE id="$id"
Copy after login
应该就没问题了

sql里面没有name列,$row['name']当然就为空了。

表里name字段为空?

表里name字段为空?

看错了,楼上说得对

$name = $row['name'];
改为
$name = isset($row['name'])? $row['name'] : 'guest';

如果显示guest,那表示数据表没有name字段,或name字段内容为空。

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