I had a problem choosing the right values ββon my mysql sql server.
ip can be ipv6 and v4.
Table: User {
...
ip binary (16)
}
$ip = '192.168.10.115'; $ip = bin2hex(inet_pton($ip)); // Returns c0a80a73 $result = $this->db->select("SELECT * FROM User WHERE HEX(ip) = $ip"); // $result empty because in db its stored as: // HEX(ip) = C0A80A73000000000000000000000000
How can I get a viable match with * 00000 *?
If the input was ipv6, that would be ok, but ip v4 is not.
php mysql select ip hex
Petter kjelkenes
source share