desjardins2010 Posted December 20, 2010 Share Posted December 20, 2010 hey guys/gals I'm using this code there to store a random ip address to users when they sign up function make_ip(){ $inum1 = rand(0,255); $inum2 = rand(0,255); $inum3 = rand(0,255); $inum4 = rand(0,255); $ip = $inum1.'.'.$inum2.'.'.$inum3.'.'.$inum4; $ip=ip2long($ip); return $ip; } function long_2IP($ip){ $display_ip=long2ip($ip); return $display_ip; } function makeUniqueIP() { do { $ip_address=make_ip(); $ip_addressExixt=''; $validateRandQuery="select IPaddress from members where IPaddress='".$ip_address."'"; $result=mysql_query($validateRandQuery) or die(mysql_error()); if($row=mysql_fetch_array($result)) { $ip_addressExixt=$row['IPaddress']; } } while($jobIdExist); return $ip_address; } Now that I have the IP sotred in the db I need to reference it when a user fills in a form searching for ip 231.45.115.29 it's stored in db as 3878515485 using log2ip i'm able to exstract if but how to I compare a submission as 231.45.115.29 to the value in the db. right now it just comes back saying that ip was not found Link to comment https://forums.phpfreaks.com/topic/222232-little-help-please/ Share on other sites More sharing options...
Pikachu2000 Posted December 20, 2010 Share Posted December 20, 2010 Again, I have to ask just what you mean by 'assigning a random ip address'? What are you trying to do? Link to comment https://forums.phpfreaks.com/topic/222232-little-help-please/#findComment-1149616 Share on other sites More sharing options...
desjardins2010 Posted December 20, 2010 Author Share Posted December 20, 2010 the ip is already done were building a GAME hacking simulation fo each user upon registration is given a FAKE ip address for in game purpose, the IP is being stored in the data base as mentioned above in a different format then the long2ip bring it out as a normal IP address problem is I need to compare an ip submitted for search as 231.45.115.29 and search the db for an account with an IP that matches that... there not being stored in the same format though so i'm not comparing apples to apples.. Link to comment https://forums.phpfreaks.com/topic/222232-little-help-please/#findComment-1149623 Share on other sites More sharing options...
Pikachu2000 Posted December 20, 2010 Share Posted December 20, 2010 Now it makes sense, but did INET_ATON() and INET_NTOA() not work for you? Link to comment https://forums.phpfreaks.com/topic/222232-little-help-please/#findComment-1149624 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.