Page 1 of 1

insert into with mysql, multidimensional arrays

Posted: Tue May 31, 2005 11:41 pm
by jaymoore_299
I can't seem to get multidimensional variables to be sent to the database. I have had no problems passing numbers, regular variables, and one dimensional arrays. I have inserted then printed out the entire database to check, and one dimensional variables have their respective values in the database, however with multidimensional arrays, I get something like Array[0], Array[1], Array[2]. Does mysql support multidimensional arrays? How do I represent them? I tried putting double quotes, without quotes, etc..

Code: Select all

$insert=mysql_query(&quote;INSERT INTO table (a,b,c,d) 
VALUES ('aї0]ї0]','aї0]ї1]','aї0]ї2]','aї0]ї3]')&quote;) 
or die ('insert unsuccessful because'.mysql_error());

Posted: Tue May 31, 2005 11:43 pm
by John Cartwright
serialize() it, insert it into db, unserialize() when you need it back

Posted: Wed Jun 01, 2005 12:51 am
by Burrito
for all intents and purposes I don't see why that didn't work.

I like JCart's suggestion of serializing the array or you could set temp vars from the parent array by grabbing values from the child within a foreach loop of the parent.