larry29936 Posted August 14, 2020 Share Posted August 14, 2020 (edited) I'm trying to get an id for a row in a lookup table based on an ip address. All ip's are stored as the result inet_aton(ip) in fields that are varbinary(16). The lookup table has ip ranges (start_ip and end_ip) and countries associated with the range. 1219006512 is the inet_aton value of a user's ip address. When I run the following query in phpmyadmin, I'm getting multiple rows. I get multiple rows with a different result set if I run the query in mysql in the terminal. Query follows: SELECT * FROM lookup WHERE ('1219006512' >= start_ip and '1219006512'<= end_ip); What am I doing wrong? Edited August 14, 2020 by larry29936 Quote Link to comment https://forums.phpfreaks.com/topic/311329-sql-query-problem/ Share on other sites More sharing options...
Barand Posted August 14, 2020 Share Posted August 14, 2020 start_id and end_id are varbinary(16) '1219006512' isn't. Quote Link to comment https://forums.phpfreaks.com/topic/311329-sql-query-problem/#findComment-1580610 Share on other sites More sharing options...
larry29936 Posted August 14, 2020 Author Share Posted August 14, 2020 @Barand - that's what I copied from the ip_address field of the user. Are you saying that inet_aton(user_ip) failed or that putting it in single quotes was wrong? Quote Link to comment https://forums.phpfreaks.com/topic/311329-sql-query-problem/#findComment-1580611 Share on other sites More sharing options...
Barand Posted August 14, 2020 Share Posted August 14, 2020 inet_aton() does not produce varbinary(16). The manual is available online should you ever want to consult it. Quote Link to comment https://forums.phpfreaks.com/topic/311329-sql-query-problem/#findComment-1580612 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.