insert into with mysql, multidimensional arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jaymoore_299
Forum Contributor
Posts: 128
Joined: Wed May 11, 2005 6:40 pm
Contact:

insert into with mysql, multidimensional arrays

Post 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());
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

serialize() it, insert it into db, unserialize() when you need it back
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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.
Post Reply