desjardins2010 Posted December 16, 2010 Share Posted December 16, 2010 hey all; I had a post in here I was getting help with and I can't figure out how to search for all my post so for that i apologize... I'm needing to give a user an ip address prob is when I try to store in the the database it don't store.. it cuts it? anyone help on how to do this and be able to refer to it per user Quote Link to comment https://forums.phpfreaks.com/topic/221924-storing-and-retv-ipaddress/ Share on other sites More sharing options...
PnzrDrgoon Posted December 16, 2010 Share Posted December 16, 2010 What kind of field are you using in the table? Have you tried lengthening it? Quote Link to comment https://forums.phpfreaks.com/topic/221924-storing-and-retv-ipaddress/#findComment-1148422 Share on other sites More sharing options...
Pikachu2000 Posted December 16, 2010 Share Posted December 16, 2010 Have a look at INET_ATON() and INET_NTOA(). Quote Link to comment https://forums.phpfreaks.com/topic/221924-storing-and-retv-ipaddress/#findComment-1148425 Share on other sites More sharing options...
desjardins2010 Posted December 16, 2010 Author Share Posted December 16, 2010 thanks thats what I was looking for I couldn't remember.... Quote Link to comment https://forums.phpfreaks.com/topic/221924-storing-and-retv-ipaddress/#findComment-1148431 Share on other sites More sharing options...
desjardins2010 Posted December 17, 2010 Author Share Posted December 17, 2010 Pikachu2000 maybe you might have a way for me to do what I'm trying to do.. I want that when the user registers to inster into IPaddress feild a random ip address, then for me to be able reference that IP later as a way of pulling that user info Quote Link to comment https://forums.phpfreaks.com/topic/221924-storing-and-retv-ipaddress/#findComment-1148435 Share on other sites More sharing options...
Pikachu2000 Posted December 17, 2010 Share Posted December 17, 2010 I don't really follow what you're asking. Quote Link to comment https://forums.phpfreaks.com/topic/221924-storing-and-retv-ipaddress/#findComment-1148440 Share on other sites More sharing options...
PFMaBiSmAd Posted December 17, 2010 Share Posted December 17, 2010 Here's your existing thread where you first asked the question - http://www.phpfreaks.com/forums/mysql-help/how-to-get-database-to-accept/ Here's your existing thread after you added inet_aton() to the code - http://www.phpfreaks.com/forums/php-coding-help/this-was-working-fine/ Quote Link to comment https://forums.phpfreaks.com/topic/221924-storing-and-retv-ipaddress/#findComment-1148447 Share on other sites More sharing options...
Viper69 Posted December 17, 2010 Share Posted December 17, 2010 hey all; I had a post in here I was getting help with and I can't figure out how to search for all my post so for that i apologize... I'm needing to give a user an ip address prob is when I try to store in the the database it don't store.. it cuts it? anyone help on how to do this and be able to refer to it per user This script works, I didnt write it but I have used it successfully to store ip addresses $ip = getRealIpAddr(); function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } Quote Link to comment https://forums.phpfreaks.com/topic/221924-storing-and-retv-ipaddress/#findComment-1148519 Share on other sites More sharing options...
desjardins2010 Posted December 17, 2010 Author Share Posted December 17, 2010 ya thats using there real IP address what I'm trying to accomplish is when a user registers for the game they are given a random IP address, this ip address is stored in the database under a field IPaddress, later I want to be able to SELECT the user if there IP address matches the one entered into a form... so really just a way of given a user a random ip address on register as a feild that is INSERTED into the database when they register and then being able to reference that IP address later... Quote Link to comment https://forums.phpfreaks.com/topic/221924-storing-and-retv-ipaddress/#findComment-1148632 Share on other sites More sharing options...
Pikachu2000 Posted December 17, 2010 Share Posted December 17, 2010 What do you mean you're going to give the user a random IP address? If it's just as it sounds, you can't do that. Quote Link to comment https://forums.phpfreaks.com/topic/221924-storing-and-retv-ipaddress/#findComment-1148677 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.