MySQL, id = $GET [' ID '] returns a null result. How to fix it
Source: Internet
Author: User
MySQL, id = $GET [' ID '] returns a null result.
The database ID entry is bigint
PHP Code:
SELECT * FROM mytable WHERE id= ' ". $GET [' id ']." '
Sometimes the results can be displayed, and sometimes the results are empty. The empty MySQL query statement is pasted into phpMyAdmin sql, which can be displayed normally.
Suspect that the $GET [' ID '] item was mistakenly considered by PHP as a string, not an int,
So add
SELECT * FROM mytable WHERE id= ' ". (int) ($GET [' ID ']). "'
The result is still empty. How to solve the problem?
------Solution--------------------
If the ID is shaped, you don't need to add a single quote, the string needs Ah!
------Solution--------------------
$GET if it's a GET method, it should be $_get.
------Solution--------------------
Cast to shaping should be intval ($_get[' id ');
------Solution--------------------
Explore
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.