Jump to content

Storing series of related strings.


Vorotaev

Recommended Posts

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.