Vorotaev Posted April 6, 2006 Share Posted April 6, 2006 I'm trying to write a simple membership system, and for security's sake, I'd like to track the various IP addresses used to access a given account. I obviously don't know what the IP addresses will be in advance, nor do I know how many of them will be used for an account. If the person uses dial-up, it could change with every single visit.If I knew there would be only one IP address, the situation would be simple; each row would contain a member's screenname, their miscellaneous information, and their IP address all bundled together nice and simple like. But since each member may need to store many IP addresses, I need something a bit more flexible.MySQL doesn't seem to have any kind of array data type. The closest thing I could find was LONGTEXT, which I could then use to produce a series of IP addresses in CSV format, which I in turn could use a PHP function like explode() to break into an array to work with. It seems like there should be a better way to handle it though.Any suggestions or information would be appreciated. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/6742-storing-series-of-related-strings/ Share on other sites More sharing options...
obsidian Posted April 6, 2006 Share Posted April 6, 2006 your best bet, since you're using a relational database would be to build a related table to store the IPs in. for instance, you'd simply need a table with 2 columns: user_id and ip_address. then, when they log in, you simply check to see whether or not that IP address is stored in relation to that user or not. if so, leave it be; if not, record it. Quote Link to comment https://forums.phpfreaks.com/topic/6742-storing-series-of-related-strings/#findComment-24521 Share on other sites More sharing options...
Vorotaev Posted April 6, 2006 Author Share Posted April 6, 2006 Ah, that sounds perfect. Thanks very much for your help. ^_^ Quote Link to comment https://forums.phpfreaks.com/topic/6742-storing-series-of-related-strings/#findComment-24524 Share on other sites More sharing options...
fenway Posted April 6, 2006 Share Posted April 6, 2006 And you could even get away with a UNIQUE index on ip_address and then just run INSERT INGOREs. Quote Link to comment https://forums.phpfreaks.com/topic/6742-storing-series-of-related-strings/#findComment-24599 Share on other sites More sharing options...
wickning1 Posted April 6, 2006 Share Posted April 6, 2006 Not if two users log in from the same IP (public machine, dynamic IP, etc). Could certainly UNIQUE on user_id,ip_address though. Quote Link to comment https://forums.phpfreaks.com/topic/6742-storing-series-of-related-strings/#findComment-24604 Share on other sites More sharing options...
fenway Posted April 7, 2006 Share Posted April 7, 2006 Yeah, that's what I meant. Quote Link to comment https://forums.phpfreaks.com/topic/6742-storing-series-of-related-strings/#findComment-24674 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.