xProteuSx Posted November 4, 2011 Share Posted November 4, 2011 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?? Quote Link to comment https://forums.phpfreaks.com/topic/250425-storing-an-array-in-a-mysql-database/ Share on other sites More sharing options...
xProteuSx Posted November 4, 2011 Author Share Posted November 4, 2011 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?? Quote Link to comment https://forums.phpfreaks.com/topic/250425-storing-an-array-in-a-mysql-database/#findComment-1284848 Share on other sites More sharing options...
xProteuSx Posted November 4, 2011 Author Share Posted November 4, 2011 Got it figured out: http://php.net/manual/en/function.serialize.php http://php.net/manual/en/function.unserialize.php Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/250425-storing-an-array-in-a-mysql-database/#findComment-1284849 Share on other sites More sharing options...
Wiro Blangkon Posted November 5, 2011 Share Posted November 5, 2011 Hi Proteus, These are also useful: http://php.net/manual/en/function.json-encode.php http://php.net/manual/en/function.json-decode.php http://nl2.php.net/manual/en/function.explode.php http://nl2.php.net/manual/en/function.implode.php Wiro. Quote Link to comment https://forums.phpfreaks.com/topic/250425-storing-an-array-in-a-mysql-database/#findComment-1285226 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.