The question is published on by Tutorial Guruji team.
$uid=intval($_GET['uid']); //98765432109876543 $sql = "SELECT * FROM accounts WHERE uid = $uid ORDER BY id DESC LIMIT 1";
Won’t return any result, PHP is 64bit.
Below I put the executed commands from mysql client. uid field is BIGINT
Output from the mysql client: mysql> SELECT * FROM accounts WHERE id = 1 ORDER BY id DESC LIMIT 1; | id | uid | paid_date | | 1 | 98765432109876543 | 2015-09-20 12:56:47 |
Output from the mysql client: mysql> SELECT * FROM accounts WHERE uid=98765432109876543 ORDER BY id DESC LIMIT 1; Empty set (0.00 sec)
So my question is, what is the reason I cannot retrieve the expected value from the first sql query?
I’ve executed your quires, just worked fine for me. You need to update your
I’ve tested with some thing like these.
First, I’ve create a
VARCHAR(50), and it returned fine results.
Check this Fiddle.
but what if you want
INT? you can’t use
INT to store more than 10 or 11 char long string(integer) because it ranges from
2147483647 and for
UNSIGNED INT ranging from
So you’ve to use
BIGINT instead, it ranges from
9223372036854775807. Check this FIDDLE.
I assume that
uid will never have value in -ve, so use
BIGINT UNSIGNED, it ranges from
18446744073709551615 and that will also work for you.
Check this FIDDLE
Hope this will help you.