PDA

View Full Version : sending array from Flash to PHP


nustart2k
04-15-2002, 06:21 AM
Hi there,

I need to send a multidimensional array out from Flash to a PHP script, to be inserted into a MYSQL database. I suspect that loadVariables does not take array as variable. Am I correct? If so, what are the ways to do that? Using cookies, or external flat file? Or do I just need to make the array into a MIME format string before sending it out using loadVariables?

I am new to backend issues, so any pointers and suggestions are greatly appreciated :)

Thank you,

John

Jesse
04-15-2002, 03:47 PM
LoadVariables does work with arrays but it send them as command separated strings, which will cause problems with multidimensional arrays. You may have to make your own function which converts an X dimensional array into a delimiterred string. There is a function by me in the Library which converts a 2D array into a string to be sent to PHP... That's the best way I can think of. XML may provide a solution but as far as I know it's not that great for exporting arrays...

nustart2k
04-16-2002, 07:16 AM
Hey Jesse,

Thank you for your advice. I shall look into creating my own function. I was looking in the library for the function that you created, and it seems that it is for converting a string to a 2D array, and not the other way round :)

John

tg
04-16-2002, 03:52 PM
i believe you could use array.join() to turn your multiD array into a string. like this:

var arr1 = new Array("1","2","3");
var arr2 = new Array("10","9","8");
var arrJoin = new Array();
var myOutputString;

arrJoin[0]=arr1;
arrJoin[1]=arr2;

myOutputString=arrJoin.join();
trace(myOutputString);

nustart2k
04-17-2002, 06:17 AM
Hey tg,

Thanks for the advice. But I just realized that I was just being silly. There is no need to pack things into an array, only to be serialized out to PHP. I should just sent them as separate variables and let PHP pack them nicely in the database! :) These packing and unpacking is redundant.

John