Newbies draad Posted February 24, 2015 Newbies Posted February 24, 2015 Hello everyone. I'm plyaing for the first time with filemaker PHP API, and, even if I succeed on doing a basic newFindRequest (), I'm stuck on something that must be very simple but I can't get working. I have a layout called "Php Ipv4 Blocks" linked to a table that keep tracks of IPs as long and the country associated to thoses IPs. My table structure looks like this : id : unique id (number) country_id : id of a country (number) integer_ip_from : starting value of ip range as long (number) integer_ip_from : ending value of ip range as long (number) In my php script, I transform an ip to a long value and then, I try to perform a newFindRequest() where integer_ip_from <= ip as long integer_ip_to >= ip as long I use this function to transfor IP to long : $longIp = printf("%un", ip2long($IP)); If I try with a random ip, for exemple : 173.176.47.188 Converted as long I find this value : 2914004924 So now, I try to perform my find : function getCountryForIp ($IP){ $longIp = printf("%un", ip2long($IP)); $findCommand = $GLOBALS["fm"]->newFindCommand("Php Ipv4 Blocks"); $findCommand->addFindCriterion("integer_ip_from", '<=' . $longIp); $findCommand->addFindCriterion("integer_ip_to" , '>=' . $longIp); $result = $findCommand->execute(); if (FileMaker::isError($result)) { echo $result->getCode(); echo $result->getMessage(); echo "No country found"; return false; } else { $record = $result->getFirstRecord(); $country = $record->getField("country_id"); echo "country id " . $country; return true; } This will return me : 401 No records match the request. Note that if for testing purpose I replace my var $longIp and input the long value directly I find my record: $longIp = 2914004924; //printf("%un", ip2long($IP)); Can you guys help me on this issue ? Thanks.
ggt667 Posted February 27, 2015 Posted February 27, 2015 I believe you should store the field for searching as FileMaker Number type( the output of ip2long() ) without the linebreak.
Recommended Posts
This topic is 3895 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now