ballhogjoni Posted October 11, 2008 Share Posted October 11, 2008 I have a database full of ip ranges like 221.134.0.0. I am trying to search the database for this based off the user ip address. My query is simple: $oDB->Select('ip_tracking','ip','WHERE ip LIKE "%'.$ip.'%"'); first param is the table name, second is what I want, third is the where clause. Quote Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/ Share on other sites More sharing options...
budimir Posted October 11, 2008 Share Posted October 11, 2008 And your problem is...?? Quote Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662709 Share on other sites More sharing options...
ballhogjoni Posted October 11, 2008 Author Share Posted October 11, 2008 it doesn't find the ip range. Quote Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662747 Share on other sites More sharing options...
CroNiX Posted October 11, 2008 Share Posted October 11, 2008 so you want it to find 221.134.* ? Quote Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662750 Share on other sites More sharing options...
ballhogjoni Posted October 11, 2008 Author Share Posted October 11, 2008 Thats correct. Quote Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662756 Share on other sites More sharing options...
CroNiX Posted October 11, 2008 Share Posted October 11, 2008 Maybe this? <?php $exip = explode('.',$ip); $newIP=$exip[0].'.'.$exip[1].'.'; $oDB->Select('ip_tracking','ip',"WHERE ip LIKE '$newIP%'"); Quote Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662763 Share on other sites More sharing options...
ballhogjoni Posted October 11, 2008 Author Share Posted October 11, 2008 perfect...thanks Quote Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662771 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.