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
https://forums.phpfreaks.com/topic/250425-storing-an-array-in-a-mysql-database/
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??

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.