Jump to content

Storing an Array in a MySQL Database


xProteuSx

Recommended Posts

I've got an array like this:

 

$firstquarter = array('January', 'February', 'March');

 

Then I'm adding it to a MySQL DB as follows:

 

$insert = "INSERT INTO sometable (months) VALUES ('$firstquarter') ";

$insertresult = mysql_query($insert) or die ('Error in Insert query: ' . mysql_error());

 

When I use PHPMyAdmin I see a this value stored in the DB:

 

'Array'

 

Can I retrieve the values, by index, from this database field??

Link to comment
Share on other sites

After some testing (keep in mind that I am pretty amateur) it seems that the word 'Array' has in itself become an array.  As in:

 

$array[0] = A

$array[1] = r

$array[2] = r

$array[3] = a

$array[4] = y

 

Is there any way of storing an array, within an array, in a database field??

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.