mysql, id = $GET['id'] 返回结果为空。该如何解决

WBOY
Release: 2016-06-13 13:40:39
Original
1135 people have browsed it

mysql, id = $GET['id'] 返回结果为空。
数据库id项为 bigint

PHP代码:

SELECT * FROM mytable WHERE id='".$GET['id']."'  

有时可以显示结果,有时结果为空。 把为空时的mysql query 语句 贴到PHPMYADMIN SQL里,可以正常显示。
怀疑 $GET['id'] 项被PHP误认为 string, 而非 int,

于是加

SELECT * FROM mytable WHERE id='".(int)($GET['id'])."'

结果结果还是为空。 到底该如何解决?

------解决方案--------------------
id为整形的话,就不用加单引号,字符串才需要啊!
------解决方案--------------------
$GET 如果是get方式传值的话就应该是 $_GET

------解决方案--------------------
强制转换成整形应该是intval($_GET['id']);
------解决方案--------------------

探讨

$GET 如果是get方式传值的话就应该是 $_GET
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!